<?php require_once( dirname(dirname(dirname( __FILE__ ))) . '/wp-load.php' ); ?>
<!-- START of header -->
<?php get_header(); ?>
<!-- END of header -->

<!-- warapper -->

<div class="docs-content">
<!-- START of page navigation -->
<?php get_template_part( 'docs_navigation' ); ?>
<!-- END of page navigation -->
<!-- START of pusher -->
<div class="docs-content-body">
<div id="content" class="docs-content-body__inner">

<h1 class="title">5.1.18 Trigger (JMS)</h1>
<h2 id="overview">Overview</h2>
<P>This section covers how to notify an application with JMS using Trigger functions. For an overview of the trigger function, please refer to the <a href="5-1-17_trigger-rest.php">Trigger (rest)</a> seciton.

<h2 id="setting-the-trigger">Setting the Trigger</h2>
<strong>List.1 Setting the Trigger</strong>(TriggerJms.java)
<pre class="prettyprint linenums:32">
// Create Connection
store = gridLogic.createGridStore();

// Create Trigger Settings
TriggerInfo trigger = new TriggerInfo();
trigger.setName("InstrumentLogJMSTrigger");
trigger.setType(Type.JMS);
trigger.setJMSDestinationType("queue");
trigger.setJMSDestinationName("jms/griddb");
trigger.setTargetEvents(EnumSet.of(EventType.PUT));
trigger.setUser("admin");
trigger.setPassword("admin");
trigger.setURI(URI.create("http://127.0.0.1:7676/"));

// Get TimeSeries Container
TimeSeries&lt;InstrumentLog&gt; logTs =
        store.getTimeSeries("weather_station_1", InstrumentLog.class);

logTs.createTrigger(trigger);
</pre>

<ul>
<li>Line 33: Create a new Trigger with the TriggerInfo() class</li>
<li>Line 34-41: Set the parameters for the trigger as necessary</li>
<li>Line 47: Create the trigger</li>
<li>Line 50-53: The a notification will be triggered when a row is updated.</li>
</ul>
<br>
<h2 id="installation-of-the-jms-server">Installation of the JMS server</h2>
<p>Note: The installation procedure is complicated so please refer to the documentation of your chosen JMS server. The necessary configuration information specific to the sample environment is as follows:</p>
<p><strong>Table 1 JMS Server Configuration</strong></p>
<div class="griddb" markdown="1">

</div>
<table>
<thead>
<tr class="header">
<th style="text-align: left;">Setting Item</th>
<th style="text-align: center;">Setting Value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Notification URI</td>
<td style="text-align: center;">http://127.0.0.1:7676/</td>
</tr>
<tr class="even">
<td style="text-align: left;">Destination type</td>
<td style="text-align: center;">queue</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Destination namejms/griddb</td>
<td style="text-align: center;"></td>
</tr>
</tbody>
</table>

<p> The following is the output of the JMS server when above code triggers an event</p>

<strong>List.4 Result</strong>
<pre class="prettyprint">
The execution result of the list second row update
TriggerJms.java the contents of the standard output of the JMS server when you run is as follows.
{
    "Container" : "Weather_station_1" , 
    "Event" : "Put" 
}
Gsnode2 . Griddb_default - - [ 13 / Sep / 2016 10 : 18 : 01 ] "POST / HTTP / 1.1" 200 - 
</pre>
<h2 id="source-code">Source Code</h2>
<p>Complete source code used in this sample can be downloaded from the following.</p>
<p>Download: <a href="img/trigger-jms.zip">trigger-jms.zip</a></p>
</div>
</div>
</div>
</div>
</div>

<!-- / main -->

<?php get_footer(); ?>
