JMS Action group in MII Workbench

You use this group of actions to communicate with a Java Message Service (JMS) server. This can be used for integration to other third party applications that use the JMS standard. The JMS API is a messaging standard that allows application components based on the Java 2 Platform, Enterprise Edition (J2EE) to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.

The JMS actions in MII Workbench include the following:

  • Queue Write
  • Queue Read
  • Topic Publish

The JMS Queue actions provide a generic system to system interface that can be used to pass unstructured messages between. For example if a customer already has JBoss or other Application servers running in their environment. It also allows for asynchronous messaging between scheduled transactions and can be used to integrate with MSMQ for mobile device notifications.

The JMS Topic Publish action can be used to asynchronously notify subscribed endpoints of a change in conditions on the shop-floor by feeding data to a UI that supports JMS Topic subscriptions (i.e.: MS Silverlight, Adobe Flash). This allows the system to push content to user(s) rather than have the user pages poll the backend systems for changes.

  1. Queue Write

You use this action to send text-based messages to an existing queue on a Java Message Service (JMS) server.

The following table lists the properties for the JMS Queue Write action:

Name / Property / Data Type / Default value / Access / Use
Connection Alias / ConnPropAlias / String / In and out / Identifies the JMS Connection alias that you want to use. This property is not mandatory – you can choose to use an alias or enter the connection details for the action manually. In case when you select an alias the URL, JNDI Context Provider and JNDI Factory Context are filled during the runtime automatically with the data from the alias. If you do not choose an alias than you should fill them with proper data. You can manage the JMS Connection aliases through System Connection Editor.
URL / JndiUrl / String / In and out / Specifies the URL for the JNDI service provider. You can find information how to construct the URL for connection to the SAP NetWeaver JNDI service provider in Creating an Initial Context -> Connection via the ICM and/or Connection via the Message Server.AS Java Portsprovides a list of ports used by SAP NetWeaver.
JNDI Context Provider / JndiContextProvider / String / In and out / Identifies the initial context factory to use.The value of the property should be the fully qualified class name of the factory class that will create an initial context.
To connect to the SAP NetWeaver JNDI Registry Service, you have to use the following initial context factory class name: com.sap.engine.services.jndi.InitialContextFactoryImpl.
JNDI Factory Context / JndiFactoryContext / String / In and out / Identifies the connection factory to use. Specifies the name that will be used for the lookup of the factory class that will create connections with a point to point JMS provider.
In case you will send messages to the SAP NetWeaver JMS provider you can use the following name: jmsfactory/default/QueueConnectionFactory.
To see all available connection factories in SAP NetWeaver you have to
-Open SAP NetWeaver Administrator
-Choose Configuration Management -> Infrastructure -> JMS Server Configuration
-Enter “JMS Connection Factory” as a Type filter in the filters row and press enter
-The table will show the available JMS Connection Factories
JNDI Credential Alias / JndiCredentialAlias / String / In and out / Specifies the alias for the user name and password that will be used for the creation of the JNDI context. You can use the Credential Editor to manage the credential aliases.
Queue Credential Alias / QueueCredentialAlias / String / In and out / Specifies the alias to the identity that will be used to create a JMS queue connection. You can use the Credential Editor to manage the credential aliases.
Queue Name / QueueName / String / In and out / Specifies the name of the queue to write to.
Message Expiration / MessageExpiration / Long / 5000 / In and out / Specifies the message lifetime in milliseconds. The message is destroyed after the specified expiration time. If the value is set to 0 the message will never expire.
Delivery Mode / DeliveryMode / Int / 2 / In and out / Specify the delivery mode for the message. There are two available modes:
-Persistent (value = 1), where the message is persisted to the database until the send attempt is successful. This ensures that the message won’t be lost in case of JMS provider failure.
-Non Persistent (value =2), message is not persisted and thus its delivery is not guarantee in case of afailure during the delivery attempts.
The default delivery mode is Non Persistent.
Priority / Priority / Int / 4 / In and out / Specifies the priority of the message. The level of priority range from 0 (low) to 9 (highest). The default priority level is 4.
Message / Message / String / In and out / Specifies the message body.
Success / Boolean / Out / Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.
  1. Queue Read

You use this action to read text-based messages from an existing queue on a Java Message Service (JMS) server. This action attempts to synchronously read from the queue.

The following table lists properties for the JMS Queue Read action:

Name / Property / Data Type / Default value / Access / Use
Connection Alias / ConnPropAlias / String / In and out / Identifies the JMS Connection alias that you want to use. This property is not mandatory – you can choose to use an alias or enter the connection details for the action manually. In case when you select an alias the URL, JNDI Context Provider and JNDI Factory Context are filled during the runtime automatically with the data from the alias. If you do not choose an alias than you should fill them with proper data. You can manage the JMS Connection aliases through System Connection Editor.
URL / JndiUrl / String / In and out / Specifies the URL for the JNDI service provider. You can find information how to construct the URL for connection to the SAP NetWeaver JNDI service provider in Creating an Initial Context -> Connection via the ICM and/or Connection via the Message Server. AS Java Portsprovides a list of ports used by SAP NetWeaver.
JNDI Context Provider / JndiContextProvider / String / In and out / Identifies the initial context factory to use.The value of the property should be the fully qualified class name of the factory class that will create an initial context.
To connect to the NetWeaver JNDI Registry Service, you have to use the following initial context factory class name: com.sap.engine.services.jndi.InitialContextFactoryImpl.
JNDI Factory Context / JndiFactoryContext / String / In and out / Identifies the connection factory to use. Specifies the name that will be used for the lookup of the factory class that will create connections with a point to point JMS provider.
In case you will consume messages from the SAP NetWeaver JMS provider you can use the following name: jmsfactory/default/QueueConnectionFactory.
To see all available connection factories in SAP NetWeaver you have to
-Open SAP NetWeaver Administrator
-Choose Configuration Management -> Infrastructure -> JMS Server Configuration
-Enter “JMS Connection Factory” as a Type filter in the filters row and press enter
-The table will show the available JMS Connection Factories
JNDI Credential Allias / JndiCredentialAlias / String / In and out / Specifies the alias for the user name and password that will be used for the creation of the JNDI context. You can use the Credential Editor to manage the credential aliases.
Queue Credential Alias / QueueCredentialAlias / String / In and out / Specifies the alias to the identity that will be used to create a JMS queue connection. You can use the Credential Editor to manage the credential aliases.
Read Timeout / ReadTimeout / Long / 5000 / In and out / Specifies the time in milliseconds that determines how long will attempt to read a message.
Queue Name / QueueName / String / In and out / Specifies the name of the queue to write to.
Message / Message / String / Out / Specifies the message body.
Success / Boolean / Out / Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.
  1. Topic Publish

You use this action to send text-based messages to an existing topic on a Java Message Service (JMS) server.

The following table lists properties for the JMS Topic Publish action:

Name / Property / Data Type / Default value / Access / Use
Connection Alias / ConnPropAlias / String / In and out / Identifies the JMS Connection alias that you want to use. This property is not mandatory – you can choose to use an alias or enter the connection details for the action manually. In case when you select an alias the URL, JNDI Context Provider and JNDI Factory Context are filled during the runtime automatically with the data from the alias. If you do not choose an alias than you should fill them with proper data. You can manage the JMS Connection aliases through System Connection Editor.
URL / JndiUrl / String / In and out / Specifies the URL for the JNDI service provider. You can find information how to construct the URL for connection to the SAP NetWeaver JNDI service provider in Creating an Initial Context -> Connection via the ICM and/or Connection via the Message Server. AS Java Portsprovides a list of ports used by SAP NetWeaver.
JNDI Context Provider / JndiContextProvider / String / In and out / Identifies the initial context factory to use.The value of the property should be the fully qualified class name of the factory class that will create an initial context.
To connect to the SAP NetWeaver JNDI Registry Service, you have to use the following initial context factory class name: com.sap.engine.services.jndi.InitialContextFactoryImpl.
JNDI Factory Context / JndiFactoryContext / String / In and out / Identifies the connection factory to use. Specifies the name that will be used for the lookup of the factory class that will create connections with a publish/subscribe JMS provider.
In case you will publish messages to the SAP NetWeaver JMS provider you can use the following name: jmsfactory/default/TopicConnectionFactory.
To see all available connection factories in SAP NetWeaver you have to
-Open SAP NetWeaver Administrator
-Choose Configuration Management -> Infrastructure -> JMS Server Configuration
-Enter “JMS Connection Factory” as a Type filter in the filters row and press enter
-The table will show the available JMS Connection Factories
JNDI Credential Alias / JndiCredentialAlias / String / In and out / Specifies the alias for the user name and password that will be used for the creation of the JNDI context. You can use the Credential Editor to manage the credential aliases.
Queue Credential Alias / QueueCredentialAlias / String / In and out / Specifies the alias to the identity that will be used to create a JMS queue connection. You can use the Credential Editor to manage the credential aliases.
Topic Name / TopicName / String / In and out / Specifies the topic name to which message will be published.
Message Expiration / MessageExpiration / Long / 5000 / In and out / Specifies the time in milliseconds, that determines how long will attempt to read a message
Delivery Mode / DeliveryMode / Int / 2 / In and out / Specify the delivery mode for the message. There are two available modes:
-Persistent (value = 1), where the message is persisted to the database until the send attempt is successful. This ensures that the message won’t be lost in case of JMS provider failure.
-Non Persistent (value =2), message is not persisted and thus its delivery is not guarantee in case of afailure during the delivery attempts.
The default delivery mode is Non Persistent.
Priority / Priority / Int / 4 / In and out / Specifies the priority of the message. The level of priority range from 0 (low) to 9 (highest). The default priority level is 4.
Message / Message / String / In and out / Specifies the message body.
Success / Boolean / Out / Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.
  1. Examples
  2. Preparation steps
  3. Create connection alias for the JMS Queue Write/Read examples

You can create a connection alias instead of entering connection data for every JMS Action. To create such alias performs the following steps:

-Access the MII Administration Menu

-Select component Data Service -> System Connection Editor

-Choose component type JMS

-Create a new entry with the following parameters:

Name: JMSQueue

Server URL: localhost:50004

JNDI Context Provider: com.sap.engine.services.jndi.InitialContextFactoryImpl

JNDI Factory Context: jmsfactory/default/QueueConnectionFactory

4.1.2.Create connection alias for the JMS Topic example

Create this alias by follow the instructions from previous point and using these parameters:

Name: JMSTopic

Server URL: localhost:50004

JNDI Context Provider: com.sap.engine.services.jndi.InitialContextFactoryImpl

JNDI Factory Context: jmsfactory/default/TopicConnectionFactory

4.1.3. Create credential store alias.

The steps to create credential alias are:

-Access the MII Administration Menu

-Select component Security Services -> Credential Editor

-Create a new entry with the following parameters:

Name: JMSConnection

User Name: <any valid user that has access to the queue>

Password: <password that matches above user>

Confirm Password: <password that matches above user>

4.1.4.Create JMS Queue

In one of the examples you will send messages to and in the other you will consume messages from that queue. To create a JMS queue in NetWeaver perform the following steps:

-Access NetWeaver Administrator

-Select Configuration Management -> Infrastructure -> JMS Server Configuration

-Create a new Queue with name MIITestQueue

-Find in the list, its name should be jmsqueues/default/MIITestQueue

4.1.5.Create JMS Topic

-Following the instructions from 4.1.4 create JMS Topic with name MIITestTopic. The full name of the topic after it is saved should be jmstopics/default/MIITestTopic.

4.2.JMS Queue Write Example

You will create a transaction that sends messages to the JMS Queue that you’ve created during the preparation steps. The number of messages that will be sent will be controlled by a global property.

4.2.1.Open the MII Workbench

4.2.2.Create new Transaction and name it JMSQueueWriteExample

4.2.3.Open the transaction global properties and create new property of type int with name JMSExamplesMsgCount and set its default value to 10.

  1. Go to Transaction tab of JMSQueueExample
  2. Locate Properties -> Global in the tree
  3. Double click on Global and you will see a new window with all global properties
  4. Click on Add button
  5. Enter JMSExampleMsgCount as a name, select int as a type and enter 10 as default value.
  6. Click on OK button
  7. You will see the new property in the list
  8. Click on OK button
  9. Change the name of the available sequence to LoopSequencе
  10. Add “While Loop” action to LoopSequence and name it WhileLoop
  1. Go to Actions tab
  2. Locate Logic Action groups
  3. Drag and drop While Loop to LoopSequence.
  4. Change the name to WhileLoop
  5. Set the maxIterations parameter of WhileLoop to the global parameter JMSExampleMsgCount
  1. Right click on WhileLoop action
  2. Select Links from the menu, Links editor will popup
  3. Browse the tree on the left and locate Globals -> JMSExampleMsgCount
  4. Browse the tree on the right and locate WhileLoop -> MaxIterations
  5. Dragand drop JMSExampleMsgGount on toMaxIteations.
  6. This will set the maximum number of iterations to the global parameter.
  7. Create new Sequence and name it JMSWriteSequence
  1. Right click on LoopSequence
  2. Select Add Sequence
  3. Add JMS Queue Write action to JMSWriteSequence and name it JMSQueueWrite
  1. In Actions tab locate JMS Action group
  2. Drag and drop Queue Write action to JMSWriteSequence
  3. Configure the JMSQueueWrite action by using the created connection and credential aliases and the queue from the preparation steps.
  1. Right click on JMSQueueWrite and select Configure. You will see JMS Queue write Configuration window
  2. Select JMSQueue from the Connection Alias drop down. The URL, JNDI Context Provider and JNDI Factory Context field will be filled with the data from the alias.
  3. Select the credential alias that you’ve created during the preparation steps
  4. Enter the name of the queue that you’ve created during the preparation steps, i.e.jmsqueues/default/MIITestQueue
  5. Enter message expiration duration. As the default value 5000(=5sec) is too small for the example please change it to 600000 (10 min).
  6. Customize the JMS message in a way you want, for example lets construct the message by using the current time, current loop iteration and some text.
  1. Right click on JMSQueueWrite and select Links, you’ll see link editor window
  2. Click on Show Expression Editor.
  3. From the tree on the right locate JMSQueueWrite -> Message and click on it, as result targetXPath will be filled with JMSQueueWrite.Message
  4. Fill the Expression text field with the following: datenow & " MII JMSQueueWriteExample message " & WhileLoop.CurrentItem
  5. Click Add button and close Link editor window
  6. Create new sequence and name it TracerSequence
  1. Right click on JMSWriteSequence
  2. Select Add Sequence
  3. Add Tracer action to TracerSequence and name it Tracer
  4. Link JMSQueueWrite->Message to the Tracer->Message
  1. Right click on Tracer, select Links
  2. From the left tree drag JMSQueueWrite->Message and drop it on the Tracer-Message from the right tree.
  3. Close link editor.
  4. Save the transaction and execute it. You’ll see messages in the traces

4.3.JMS Queue Read Example