OE11.5.1 ActiveMQ Generic JMS adapter sample

Posted by cverbiest on 08-Jun-2015 07:13

Is there sample code available demonstrating the use of the JMS adapter with an ActiveMQ.

https://community.progress.com/community_groups/openedge_development/m/documents/1986.aspx contains only very small code fragments.

The only samples I found in the documentation relate to SonicMQ .

I tried replacing the soniq url with an activemq url but I don't see which part the OE nameserver should play here.

The code below gives following error

---------------------------
Error (Press HELP to view stack trace)
---------------------------
Application Service adapter.progress.jms not found at NameServer at Host 127.0.0.1 Port 5162. (8245)
---------------------------
OK   Help   
---------------------------

DEFINE VARIABLE hConsumer AS HANDLE NO-UNDO.
DEFINE VARIABLE hPubSubSession AS HANDLE NO-UNDO.
message "starting"
view-as alert-box.
/* Creates the Pub/Sub session. */
/* RUN jms/pubsubsession.p persistent SET hPubSubSession ("-H localhost -S 5162 "). */
RUN jms/pubsubsession.p persistent SET hPubSubSession ("").

/*Connects to the broker */
RUN setBrokerURL IN hPubSubSession ("tcp://sampleHost:61616").
RUN beginSession IN hPubSubSession.
/* Subscriptes to the newTopic topic. Received messages are handled by the
myintproc internal procedure. */
RUN createMessageConsumer IN hPubSubSession
(THIS-PROCEDURE, "myintproc", OUTPUT hConsumer).
/* Subscribes to newtopic */
RUN SUBSCRIBE IN hPubSubSession ("newTopic", ?, ?, NO, hConsumer).
/* Start receiving requests */
RUN startReceiveMessages IN hPubSubSession.
/* Wait to receive the messages. */
WAIT-FOR u1 OF THIS-PROCEDURE.
/* Delete session */
RUN deleteSession IN hPubSubSession.


message "Done".


PROCEDURE myintproc:
DEFINE INPUT PARAMETER hMessage AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER hConsumer AS HANDLE NO-UNDO.
DEFINE OUTPUT PARAMETER hReply AS HANDLE NO-UNDO.
/* Business logic here */
. . .
/* Delete message. */
RUN deleteMessage IN hMessage.
APPLY "U1" TO THIS-PROCEDURE.
END.

I have activemq running and currently use it with a stomp client.

All Replies

Posted by Bill Wood on 08-Jun-2015 07:54
Posted by Anand Adike on 09-Jun-2015 03:38

Please find the attached Generic JMS Adapter Samples for Apache Active MQ.

Thanks,

Anand.

Posted by prmundra on 09-Jun-2015 06:21

RUN jms/pubsubsession.p persistent SET hPubSubSession ("-H localhost -S 5162 ").

Above statement makes use of the NameServer to search the Sonic Adapter service

The statement is commented out in your case which is causing the error message.

An alternative to skipping NameServer and connecting directly to the Sonic Adapter Broker is using DirectConnect:

RUN jms/pubsubsession.p persistent SET hPubSubSession ("-H localhost -DirectConnect -S 3620 -AppService sonicMQ1,,").


The statement:

RUN setBrokerURL IN pubsubsession (INPUT "tcp://localhost:61616"). is a directive for the Generic Adapter to connect to the ActiveMQ url as given in the Input.

So, to summarize the process is 2 step:

1) Connect to the Generic JMS Adapter (either directly or via NameServer)

2) Tell JMS Adapter the ActiveMQ connection url using the setBrokerURL method.

RUN setBrokerURL IN hPubSubSession ("tcp://sampleHost:61616"). - See more at: https://community.progress.com/community_groups/openedge_development/f/19/t/18471/reply.aspx?tsid=53736244-54ac-4fd5-af70-661c6a90ea89#sthash.aV3E8COK.dpuf
RUN setBrokerURL IN hPubSubSession ("tcp://sampleHost:61616"). - See more at: https://community.progress.com/community_groups/openedge_development/f/19/t/18471/reply.aspx?tsid=53736244-54ac-4fd5-af70-661c6a90ea89#sthash.aV3E8COK.dpuf

Posted by lucooms on 09-Jul-2015 02:19

Hello Carl

We realized a first connect Progress v11.5.1 -> Generic JMS adapter -> IBM Websphere on windows.

On linux we will try later .

You need to take every word from the white paper literally.

1) Install Websphere client

2) Create a JNDI .build file for IBM your Websphere  environment with the connection inside

3) Create the jmsfromABL.AdminObjectFinder.java class file pointing to where your JNDI .build file is located

4) Adapt the jmsProvider.properties file as described in the white paper

5) Adapt the AdminServerPlugins.properties file with the JAR file created in point 2 see whitepaper

6) Start the admin server

7) Start your appserver

8) Start the Sonic MQ adapter ( Progress can you give this product another name ? )

9) Run the program below on your appserver

Where AD.soniMQ1 is the name of your Sonic MQ adapter

Where BuilsCF  is pointing to the object in the .build JNDI file

Where central.dev is pointing to the Qeue

/* Publishes A Text message. */

DEFINE VARIABLE ptpsession AS HANDLE.

DEFINE VARIABLE messageH AS HANDLE.

DEFINE VARIABLE iping AS INTEGER    NO-UNDO INITIAL 20.

DEFINE VARIABLE lDebug AS LOGICAL.

DEFINE VARIABLE cdate AS CHARACTER NO-UNDO FORMAT "x(16)".

DEFINE VARIABLE ddate AS DATE      NO-UNDO.

/* Creates a session object. */

RUN jms/jmssession.p PERSISTENT SET ptpsession ("-AppService AD.sonicMQ1 ").

/* Set user credentials. */

RUN setBrokerURL      IN ptpsession (INPUT "BuilsCF").

RUN setUser           IN ptpsession (INPUT "admin").

RUN setPassword       IN ptpsession (INPUT "admin").

/* Connect to the broker. */

RUN beginSession IN ptpsession.

/* Create a text message */

RUN createTextMessage IN ptpsession (OUTPUT messageH).

ddate = DATE(cdate).

RUN setText IN messageH ("This is test message sent on " + STRING(TIME,"HH:MM:SS")).

/* Publish the message on the "Sample.Q1" topic */

RUN sendToQueue IN ptpsession ("central.dev", messageH, ?, ?, ?).  

RUN deleteMessage IN messageH.

RUN deleteSession IN ptpsession

This thread is closed