how to use aq jms in soa suite 11g

16
How to use AQ JMS in SOA Suite 11g I am using the following docs to set up this test case. Document1 Document2 As per the first document i have created a queue table ,a queue and have started it using following commands connect / as sysdba; Grant connect, resource TO jmsuser IDENTIFIED BY jmsuserpwd; Grant aq_user_role TO jmsuser; Grant execute ON sys.dbms_aqadm TO jmsuser; Grant execute ON sys.dbms_aq TO jmsuser; Grant execute ON sys.dbms_aqin TO jmsuser; Grant execute ON sys.dbms_aqjms TO jmsuser; Create queue table exec DBMS_AQADM.CREATE_QUEUE_TABLE(Queue_table =>'arpit',Queue_payload_type =>'sys.aq$_jms_text_message',multiple_consumers =>false); create queue EXEC DBMS_AQADM.CREATE_QUEUE(queue_name =>'ankit',queue_table =>'arpit'); exec DBMS_AQADM.START_QUEUE('ankit'); Now following steps 1>Create a data source to connect to the queue created log in to Admin console Go to data sources as indicated and create a new data source. give it some qunique name such as jdbc/SampleAQJMSDataSource

Upload: srinivas-gupta-gouru

Post on 07-Mar-2015

230 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: How to Use AQ JMS in SOA Suite 11g

How to use AQ JMS in SOA Suite 11g I am using the following docs to set up this test case.

Document1

Document2

As per the first document i have created a queue table ,a queue and have started it using following commands

connect / as sysdba;Grant connect, resource TO jmsuser IDENTIFIED BY jmsuserpwd;Grant aq_user_role TO jmsuser;Grant execute ON sys.dbms_aqadm TO jmsuser;Grant execute ON sys.dbms_aq TO jmsuser;Grant execute ON sys.dbms_aqin TO jmsuser;Grant execute ON sys.dbms_aqjms TO jmsuser;

Create queue table

exec DBMS_AQADM.CREATE_QUEUE_TABLE(Queue_table =>'arpit',Queue_payload_type =>'sys.aq$_jms_text_message',multiple_consumers =>false);

create queue

EXEC DBMS_AQADM.CREATE_QUEUE(queue_name =>'ankit',queue_table =>'arpit');

exec DBMS_AQADM.START_QUEUE('ankit');

Now following steps

1>Create a data source to connect to the queue created

log in to Admin console

Go to data sources as indicated and create a new data source.give it some qunique name such as jdbc/SampleAQJMSDataSource

Page 2: How to Use AQ JMS in SOA Suite 11g

Provide details for the database you want to connect

Verify the user name and password that you have just created

target it to the soa server

Page 3: How to Use AQ JMS in SOA Suite 11g

now go to admin console

Services-->Messaging -->JMS module and create a JMS module

Now as per document create a Foreign server in the JMS module

In the foreign server(JMS System Module Resource) select Foreign Server option, you need to take care of two things

1>JNDI Initial Context Factory: is essentially set to "oracle.jms.AQjmsInitialContextFactory" no need to add subdeployment.2>In the JNDI properties you have to set the jndi for your data sourcewhich should appear like this

datasource=jdbc/SampleAQJMSDataSource

Here jdbc/SampleAQJMSDataSource is the name of the data source i have used in my case to connect to the queues that i have created.

If you will check the document it corresponds to following configuration

<foreign-server><initial-context-factory>oracle.jms.AQjmsInitialContextFactory</initial-context-factory><jndi-property><key>datasource</key><value>jdbc/aqjmsds</value></jndi-property></foreign-server>

Page 4: How to Use AQ JMS in SOA Suite 11g

Now click on connection factory tab and provide the following details

In the local JNDI -jms/myCF

In Remote JNDI Name:XAQueueConnectionFactory

This is as per the document

Now Further click on Destination tab and create local and remote jndi

The use case and how these works internally has been explained in the document.

Page 5: How to Use AQ JMS in SOA Suite 11g

Here i am talking only about a working scenario.

So as per document provide some unique local JNDI which server will use to connect to the destination.I have specified it as jms/myQueue

Further in the Remote JNDI name provide the value as Queues/ankit

Here ankit is the name of my queue,you have to replace this with the name of your queue.

Once done save these changes.

In JMS modules , select the module created, select subdeployments tab,create new Provide name and click Next Select target Server : eg., soa_server1

Now once you will save the changes it will ask you to restart the server.Restart the server to make the changes take effect

Page 6: How to Use AQ JMS in SOA Suite 11g

Now there is one more settings that we need to do which the document doesn't talk about.We need to create an outbound connection pool for JMS adapter to be used in jdeveloper.

So i went to Deployment-->JMS Adapter-->configuration and Outbound connection pool and created an outbound connection pool

eis/SureshQueue as shown in the list

Now once the outbound connection pool is created go to the connection and go to properties tab

Page 7: How to Use AQ JMS in SOA Suite 11g

In the properteis tab in connection factory location

provide the connection factory that you have created for your foreign server.

The conenctionfactory will be the local JNDI for the connection factory as shown below ==jms/myCF

Save the changes and update your JMS adapter deployment.

Now we will create a simple bpel process to test the functionality of the process.

Just create a simple asynchronous BPEL process

Page 8: How to Use AQ JMS in SOA Suite 11g

Now drag and drop a JMS adapter in the external reference swinlane and start doing the configuration

select oracle adavanced queuing as option

Page 10: How to Use AQ JMS in SOA Suite 11g

NOw pay attenstion in the following configuration

as you can see the Destination name is taking the value which we have specified for local jndi in our destination for foreign server

Further i am using eis/SureshQueue for JMS connection

Page 11: How to Use AQ JMS in SOA Suite 11g

Use your schema or use opaque schema as per your business need to complete the process.Once process is complete drag a wire from bpel process to the adapter you have created so in all you composite should look like this

Further go to your bpel process and drag a drop an invoke activity and assign activity to copy input variable to the input of invoke activity so your bpel process should look something like this after completion

Now deploy the process and check this

Once you will invoke the process you might get an error like this

Page 12: How to Use AQ JMS in SOA Suite 11g

Specifically you will get the following error message

Error Message: {http://schemas.oracle.com/bpel/extension}bindingFaultFault ID default/AQJMS!1.0*soa_3f7f4fbd-e72e-4fdd-9820-16e30daab15c/BPELProcess1/80011-BpInv0-BpSeq0.3-3Fault Time Mar 25, 2011 1:03:34 PMNon Recoverable System Fault :<bpelFault><faultType>0</faultType><bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Produce_Message' failed due to: [Connector:199175]This ManagedConnection is managed by container for its transactional behavior and has been enlisted to JTA transaction by container; application/adapter must not call the local transaction begin/commit/rollback API. Reject event LOCAL_TRANSACTION_STARTED from adapter.". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary></part><part name="detail"><detail>[Connector:199175]This ManagedConnection is managed by container for its transactional behavior and has been enlisted to JTA transaction by container; application/adapter must not call the local transaction begin/commit/rollback API. Reject event LOCAL_TRANSACTION_STARTED from adapter.</detail></part><part name="code"><code>null</code></part></bindingFault></bpelFault>

Page 13: How to Use AQ JMS in SOA Suite 11g

Error Message: Fault ID reference:40011Fault Time Mar 25, 2011 1:03:34 PMNon Recoverable System Fault :Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Produce_Message' failed due to: [Connector:199175]This ManagedConnection is managed by container for its transactional behavior and has been enlisted to JTA transaction by container; application/adapter must not call the local transaction begin/commit/rollback API. Reject event LOCAL_TRANSACTION_STARTED from adapter.". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.

It took me a long time to resolve this issue.

By default when you are configuring the process from jdeveloper

a default outbound connection pool is used that is

eis/aqjms/Queue

YOu have to use only this one.

So Just go to your admin console

Go to Deployment-->JMS Adapter

Configuration_>Outbound connection pool and click on eis/aqjms/Queue

Go to properties tab and in the connection factory location specify the local jndi of the connection factory that you have created,which in our case is jms/myCF

Now update your JMS Adapter and change the jndi name in your Jdeveloper also.

Redeploy the process and test it again.

This time it should work fine.

Page 14: How to Use AQ JMS in SOA Suite 11g

now you can log in to database with the user and password and do a query on the table to know if the process completed successfully or not.In my case i have called it twice so i am getting a count of 2.