You use this group of actions to communicate with a

advertisement

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

Connectio n Alias

Property

ConnPropAlias

Data

Type

String

Defa ult valu e

Acces s

Use

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

URL JndiUrl String

JNDI

Context

Provider

JndiContextProvider String

JNDI

Factory

Context

JndiFactoryContext String

JNDI

Credential

Alias

JndiCredentialAlias String

Queue

Credential

QueueCredentialAlias String

In and out

In and out

In and out

In and out

In and out data. You can manage the JMS

Connection aliases through System

Connection Editor .

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 Ports provides a list of ports used by SAP NetWeaver.

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.InitialC

ontextFactoryImpl.

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/QueueConnection

Factory.

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

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.

Specifies the alias to the identity that will be used to create a JMS queue

Alias

Queue

Name

Message

Expiration

Delivery

Mode

Priority

Message

QueueName

MessageExpiration

DeliveryMode

Priority

Message

Success

String

Long

Int

Int

String

Boolean

In and out

5000 In and out

2

4

In and out

In and out

In and out

Out connection. You can use the

Credential Editor to manage the credential aliases.

Specifies the name of the queue to write to.

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.

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 a failure during the delivery attempts.

The default delivery mode is Non

Persistent.

Specifies the priority of the message. The level of priority range from 0 (low) to 9 (highest). The default priority level is 4.

Specifies the message body.

Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.

2. 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

Connectio n Alias

Property

ConnPropAlias

Data

Type

String

Defa ult valu e

Acces s

In and out

Use

Identifies the JMS Connection alias that you want to use. This property is not mandatory – you can choose

URL JndiUrl String

JNDI

Context

Provider

JndiContextProvider String

JNDI

Factory

Context

JndiFactoryContext String

In and out

In and out

In and out 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 .

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 Ports provides a list of ports used by SAP NetWeaver.

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.InitialC

ontextFactoryImpl.

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/QueueConnection

Factory.

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

JNDI

Credential

Allias

Queue

Credential

Alias

Read

Timeout

Queue

Name

JndiCredentialAlias

QueueCredentialAlias

ReadTimeout

QueueName

Message Message

Success

String

String

Long

String

String

Boolean

In and out

In and out

5000 In and out

In and out

Out

Out

- The table will show the available JMS Connection

Factories

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.

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.

Specifies the time in milliseconds that determines how long will attempt to read a message.

Specifies the name of the queue to write to.

Specifies the message body.

Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.

3. 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

Connectio n Alias

Property

ConnPropAlias

Data

Type

String

Defa ult valu e

Acces s

In and out

Use

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

URL JndiUrl String

JNDI

Context

Provider

JndiContextProvider String

JNDI

Factory

Context

JndiFactoryContext String

JNDI

Credential

Alias

JndiCredentialAlias String

Queue

Credential

Alias

QueueCredentialAlias String

In and out

In and out

In and out

In and out

In and out

Connection Editor .

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 Ports provides a list of ports used by SAP NetWeaver.

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.InitialC

ontextFactoryImpl.

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/TopicConnectionF actory.

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

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.

Specifies the alias to the identity that will be used to create a JMS queue connection. You can use the

Topic

Name

Message

Expiration

Delivery

Mode

Priority

Message

TopicName

MessageExpiration

DeliveryMode

Priority

Message

Success

String

Long

Int

Int

String

Boolean

In and out

5000 In and out

2

4

In and out

In and out

In and out

Out

Credential Editor to manage the credential aliases.

Specifies the topic name to which message will be published.

Specifies the time in milliseconds, that determines how long will attempt to read a message

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 a failure during the delivery attempts.

The default delivery mode is Non

Persistent.

Specifies the priority of the message. The level of priority range from 0 (low) to 9 (highest). The default priority level is 4.

Specifies the message body.

Indicates whether the action succeeded or failed. If it failed, errors are displayed in the server trace log.

4. Examples

4.1. Preparation steps

4.1.1. 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

4.2.4. Change the name of the available sequence to LoopSequenc е

4.2.5. 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

4.2.6. 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. Drag and drop JMSExampleMsgGount on to MaxIteations .

6. This will set the maximum number of iterations to the global parameter.

4.2.7. Create new Sequence and name it JMSWriteSequence

1. Right click on LoopSequence

2. Select Add Sequence

4.2.8. 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

4.2.9. 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).

4.2.10. 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

4.2.11. Create new sequence and name it TracerSequence

1. Right click on JMSWriteSequence

2. Select Add Sequence

4.2.12. Add Tracer action to TracerSequence and name it Tracer

4.2.13. 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.2.14. Save the transaction and execute it. You’ll see messages in the traces

4.3. JMS Queue Read Example

You will create a transaction that will consume messages send by the previous example – JMS

Queue Write Example.

4.3.1. Create new Transaction and name it JMSQueueReadExample

4.3.2. Change the name of the available sequence to LoopSequenc е

4.3.3. Add “While Loop” action to LoopSequence and name it WhileLoop

5. Go to Actions tab

6. Locate Logic Action groups

7. Drag and drop While Loop to LoopSequence .

8. Change the name to WhileLoop

4.3.4. Set the maxIterations parameter of WhileLoop to the global parameter

JMSExampleMsgCount

7. Right click on WhileLoop action

8. Select Links from the menu, Links editor will popup

9. Browse the tree on the left and locate Globals -> JMSExampleMsgCount

10. Browse the tree on the right and locate WhileLoop -> MaxIterations

11. Drad JMSExampleMsgGount and drop it on MaxIteations .

12. This will set the maximum number of iterations to the global parameter.

4.3.5. Create new Sequence and name it JMSReadSequence

3. Right click on LoopSequence

4. Select Add Sequence

4.3.6. Add JMS Queue Read action to JMSReadSequence and name it JMSQueueRead

3. In Actions tab locate JMS Action group

4. Drag and drop Queue Read action to JMSreadSequence

4.3.7. Configure the JMSQueueRead action by using the created connection and credential aliases and the queue from the preparation steps.

6. Right click on JMSQueueRead and select Configure . You will see JMS Queue Read

Configuration window

7. Select JMSQueue from the Connection Alias drop down. The URL, JNDI Context

Provider and JNDI Factory Context filled will be filled with the data from the alias.

8. Select the credent ial alias that you’ve created during the preparation steps

9. Enter the name of the queue that you’ve created during the preparation steps, i.e. jmsqueues/default/MIITestQueue .

4.3.8. Create new sequence and name it TracerSequence

3. Right click on JMSReadSequence

4. Select Add Sequence

4.3.9. Add Tracer action to TracerSequence and name it Tracer

4.3.10. Link JMSQueueRead -> Message to the Tracer -> Message in order to trace what messages are received

4. Right click on Tracer, select Links

5. From the left tree drag JMSQueueRead -> Message and drop it on the Tracer >

Message from the right tree.

6. Close link editor.

4.3.11. Save the transaction and execute it. Most probably you won’t see any messages because the messages that were sent with the previous example have been expired.

4.3.12. Run previous example (JMS Queue Write Example)

4.3.13. Run again this example, now you will see that messages are consumed by the example.

Please keep in mind that messages have expiration time, after that they are destroyed and cannot be consumed.

4.4. JMS Topic Example

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

4.4.1. Open the MII Workbench

4.4.2. Create new Transaction and name it JMSTopicExample

4.4.3. Change the name of the available sequence to LoopSequenc е

4.4.4. Add “While Loop” action to LoopSequence and name it WhileLoop

9. Go to Actions tab

10. Locate Logic Action groups

11. Drag and drop While Loop to LoopSequence .

12. Change the name to WhileLoop

4.4.5. Set the maxIterations parameter of WhileLoop to the global parameter

JMSExampleMsgCount

13. Right click on WhileLoop action

14. Select Links from the menu, Links editor will popup

15. Browse the tree on the left and locate Globals -> JMSExampleMsgCount

16. Browse the tree on the right and locate WhileLoop -> MaxIterations

17. Drag and drop JMSExampleMsgGount to MaxIteations .

18. This will set the maximum number of iterations to the global parameter.

4.4.6. Create new Sequence and name it JMSTopicSequence

5. Right click on LoopSequence

6. Select Add Sequence

4.4.7. Add JMS Topic Publish action to JMSTopicSequence and name it JMSTopicPublish

5. In Actions tab locate JMS Action group

6. Drag and drop Topic Publish action to JMSTopicSequence

4.4.8. Configure the JMSTopicPublish action by using the created connection and credential aliases and the queue from the preparation steps.

10. Right click on JMSTopicPublish and select Configure . You will see JMS Queue write

Configuration window

11. Select JMSTopic 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.

12. Select the credential alias that you’ve created during the preparation steps

13. Enter the name of the queue that you’ve created during the preparation steps, i.e. jmsqueues/default/MIITestTopic

4.4.9. 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.

6. Right click on JMSTopicPublish and select Links, you’ll see link editor window

7. Click on Show Expression Editor.

8. From the tree on the right locate JMSTopicPublish -> Message and click on it, as result targetXPath will be filled with JMSTopicPublish.Message

9. Fill the Expression text field with the following : datenow & " MII JMS Topic Example message " & WhileLoop.CurrentItem

10. Click Add button and close Link editor window

4.4.10. Create new sequence and name it TracerSequence

5. Right click on JMSTopicSequence

6. Select Add Sequence

4.4.11. Add Tracer action to TracerSequence and name it Tracer

4.4.12. Link JMSTopicPublishWrite -> Message to the Tracer -> Message

7. Right click on Tracer, select Links

8. From the left tree drag JMSTopicPublish -> Message and drop it on the Tracer ->

Message from the right tree.

9. Close link editor.

4.4.13. Save the transaction and execute it. You’ll see messages in the traces

4.5. Exported examples:

JMSQueueWriteExample.trx

JMSQueueReadExample.trx

JMSTopicExample.trx

Download