cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure Queue and QueueConnectionFactory for a MDB

Former Member
0 Kudos

Hi *,

I want to send some messages from a session bean to a message driven bean. Therefore I'll use the default Queue (sapDemoQueue) and QueueConnectionFactory.

In the ServiceLocator of my SessionBean I do the lookup with following methods:

public QueueConnectionFactory getQueueConnectionFactory() throws NamingException {

if (queueConnectionFactory == null) {

Object obj = ctx.lookup("jmsfactory/default/QueueConnectionFactory");

queueConnectionFactory = (QueueConnectionFactory) obj;

}

return queueConnectionFactory;

}

public Queue getQueue() throws NamingException {

if (queue == null) {

Object obj = ctx.lookup("jmsqueues/default/sapDemoQueue");

queue = (Queue) obj;

}

return queue;

}

My Message Driven Bean is configure as followed:

ejb-jar.xml:

<message-driven>

<ejb-name>ExportBean</ejb-name>

<ejb-class>de.test.ejb.abschluss.ExportBean</ejb-class>

<transaction-type>Container</transaction-type>

<message-driven-destination>

<destination-type>javax.jms.Queue</destination-type>

</message-driven-destination>

</message-driven>

ejb-j2ee-engine.xml:

<enterprise-bean>

<ejb-name>ExportBean</ejb-name>

<message-props>

<destination-name>jmsqueues/default/sapDemoQueue</destination-name>

<connection-factory-name>jmsfactory/default/QueueConnectionFactory</connection-factory-name>

</message-props>

</enterprise-bean>

I also create a jms-factories.xml and a jms-destination.xml.

EAR-Project/META-INF/jms-factories.xml:

<jms-factories>

<connection-factory>

<factory-name>jmsfactory/default/QueueConnectionFactory</factory-name>

<context-factory-type>

<link-factory-name>jmsfactory/default/QueueConnectionFactory</link-factory-name>

<initial-context-factory>com.sap.engine.services.jndi.InitialContextFactoryImpl</initial-context-factory>

<provider-url>localhost</provider-url>

<security-principal>Administrator</security-principal>

</context-factory-type>

<client-id></client-id>

</connection-factory>

</jms-factories>

EAR-Project/META-INF/jms-destination.xml:

<jms-destinations>

<destination>

<connection-factory>jmsfactory/default/QueueConnectionFactory</connection-factory>

<destination-name>jmsqueues/default/sapDemoQueue</destination-name>

</destination>

</jms-destinations>

How to configure correctly?

Does anybody an example how to configure?

Where may I download the example of the SAP documentation at http://help.sap.com/saphelp_nw04/helpdata/en/3d/41bee546e94ad48537f2cf06a29818/frameset.htm

Thank a lot,

Juergen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Juergen,

You can deploy and test the MDB example from the documentation, as well as download the source code on the start page of the SAP Web AS Java - just type http://<host>:<http_port>; in your browser and then go to J2EE Engine Examples -> Message-Driven Bean Example.

In the jms-factories.xml you can specify whatever for <factory-name>. For example, you could enter the following:

<jms-factories>

<connection-factory>

<factory-name>MyTestFactory</factory-name>

<context-factory-type>

<link-factory-name>jmsfactory/default/QueueConnectionFactory</link-factory-name>

Then in the jms-destinations.xml you should enter the lookup name of the factory. The destination name is arbitrary as well. For example:

<connection-factory>MyTestFactory</connection-factory>

<destination-name>MyTestQueue</destination-name>

In addition, you must set references to these resources in the ejb-jar.xml of your beans. The MDB example from the documentation provides a sample of the beans' deployment descriptors. For example:

<resource-ref>

<res-ref-name>MyTestFactory</res-ref-name>

<res-type>javax.jms.QueueConnectionFactory</res-type>

<res-auth>Container</res-auth>

</resource-ref>

<resource-env-ref>

<resource-env-ref-name>MyTestQueue</resource-env-ref-name>

<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>

</resource-env-ref>

To look up the resources in the enterprise beans, use the strings "java:comp/env/MyTestFactory" and "java:comp/env/MyTestQueue" for the factory and the destination respectively.

For more information about JMS development in SAP Web AS Java, please have a look at the documentation: http://help.sap.com/saphelp_nw04/helpdata/en/a3/63af1bbf09469fa1615c05f0daff6f/frameset.htm.

I hope this info is helpful and not too confusing:)

Zornitsa

Former Member
0 Kudos

Hi Zornitsa,

thank you for your answer. Now I can configure the Queue and the QueueConnectionFactory in jms-factories.xml and jms-destinations.xml

But it doesn't work.

I sent messages from the session bean and it seems that the messages are in the queue, but the MDB doesn't receives any messages.

BTW, the resource-ref and resource-env-ref in the MDB are not necessary they must be placed in the session bean which sends the messages.

Do you know how to watch / monitor a queue? How many messages are contained and so on?

Thanks,

Jürgen

Former Member
0 Kudos

Hi Juergen,

I would suggest that you have a look at the source code of the MDB example to make sure that you have implemented the business logic in the MDB properly.

Regarding your question about monitoring the messages in a queue, I don't think there's a tool for that. Perhaps, you can do it programmatically (I'm not an expert in JMS but maybe the QueueBrowser interface in the javax.jms package would do, what do you think?).

The resource-ref and resource-env-ref are required if you access the relevant resources in your bean. In the session bean you look up the connection factory and the queue, therefore you need the references.

Zornitsa

0 Kudos

Hi Juergen,

I think that what Zornitsa has suggested should work. How do you know that the messages are successfully sent by the session bean? Is the destination name specified in the jms-destinations.xml, session and message-driven beans descriptors all the same? Perhaps the message is sent to one Queue but the message-driven bean is listening on another... You can also check the defaultTrace file of the J2EE Engine in case there are some exceptions logged there.

You can post here all of your final descriptors again (ejb-jar, ejb-j2ee-engine, jms-factories and jms-destinations), just in case.

Best regards,

Vesselin.

Former Member
0 Kudos

Hello Vesselin

My deployment descriptors:

ejb-jar.xml

<session>

<ejb-name>MonatsabschlussBean</ejb-name>

<home>de.filiadata.leistungserfassung.ejb.abschluss.MonatsabschlussHome</home>

<remote>de.filiadata.leistungserfassung.ejb.abschluss.Monatsabschluss</remote>

<local-home>de.filiadata.leistungserfassung.ejb.abschluss.MonatsabschlussLocalHome</local-home>

<local>de.filiadata.leistungserfassung.ejb.abschluss.MonatsabschlussLocal</local>

<ejb-class>de.filiadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

<resource-ref>

<res-ref-name>FdlbQueueConnectionFactory</res-ref-name>

<res-type>javax.jms.QueueConnectionFactory</res-type>

<res-auth>Container</res-auth>

</resource-ref>

<resource-env-ref>

<resource-env-ref-name>FdlbQueue</resource-env-ref-name>

<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>

</resource-env-ref>

</session>

<message-driven>

<ejb-name>ExportBean</ejb-name>

<ejb-class>de.filiadata.leistungserfassung.ejb.abschluss.ExportBean</ejb-class>

<transaction-type>Container</transaction-type>

<message-driven-destination>

<destination-type>javax.jms.Queue</destination-type>

</message-driven-destination>

<resource-ref>

<res-ref-name>FdlbQueueConnectionFactory</res-ref-name>

<res-type>javax.jms.QueueConnectionFactory</res-type>

<res-auth>Container</res-auth>

</resource-ref>

<resource-env-ref>

<resource-env-ref-name>FdlbQueue</resource-env-ref-name>

<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>

</resource-env-ref>

</message-driven>

ejb-j2ee-engine.xml

<enterprise-bean>

<ejb-name>MonatsabschlussBean</ejb-name>

<session-props/>

</enterprise-bean>

<enterprise-bean>

<ejb-name>ExportBean</ejb-name>

<message-props>

<destination-name>FdlbQueue</destination-name>

<connection-factory-name>FdlbQueueConnectionFactory</connection-factory-name>

</message-props>

</enterprise-bean>

jms-factories.xml

<jms-factories>

<connection-factory>

<factory-name>FdlbQueueConnectionFactory</factory-name>

<context-factory-type>

<link-factory-name>jmsfactory/default/XAQueueConnectionFactory</link-factory-name>

<initial-context-factory>com.sap.engine.services.jndi.InitialContextFactoryImpl</initial-context-factory>

<provider-url>localhost</provider-url>

<security-principal>Administrator</security-principal>

<security-credentials></security-credentials>

</context-factory-type>

</connection-factory>

</jms-factories>

jms-destinations.xml

<jms-destinations>

<destination>

<connection-factory>FdlbQueueConnectionFactory</connection-factory>

<destination-name>FdlbQueue</destination-name>

</destination>

</jms-destinations>

And I'll put mit ServiceLocator:

public QueueConnectionFactory getQueueConnectionFactory() throws NamingException {

if (queueConnectionFactory == null) {

Object obj = ctx.lookup("java:comp/env/FdlbQueueConnectionFactory");

queueConnectionFactory = (QueueConnectionFactory) obj;

}

return queueConnectionFactory;

}

public Queue getQueue() throws NamingException {

if (queue == null) {

Object obj = ctx.lookup("java:comp/env/FdlbQueue");

queue = (Queue) obj;

}

return queue;

}

Kind Regards,

Juergen

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks all for helping to solve my problem.

The problem persists at my workstation, but at the workstation of my colleague it works.

Kind regards,

Juergen

Former Member
0 Kudos

Hello Jürgen,

could you tell me how you solved the problem below? (I got the same one...)

Thank in advance!

Nadine

************

Hello,

now I find an error:

#1.5#00028A35478900440000002C0000033C0003E5E9B30AD977#1097216853157#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error#1#/System/Server#Plain###JMS Connector Container Application: sap.com/LeistungserfassungEar factory name: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A35478900440000002D0000033C0003E5E9B30C13E9#1097216853238#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###Factory: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A3547890036000000010000033C0003E5E9B4B6C830#1097216885804#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#sap.com/LeistungserfassungEar#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#Guest#2####369d536018f311d9ae2600028a354789#SAPEngine_Application_Thread[impl:3]_39##0#0#Debug#1#/System/Database#Plain###exportMonatsabschlussToSap#

Former Member
0 Kudos

Hello Jürgen,

could you tell me how you solved the problem below? (I got the same one...)

Thank in advance!

Nadine

************

Hello,

now I find an error:

#1.5#00028A35478900440000002C0000033C0003E5E9B30AD977#1097216853157#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error#1#/System/Server#Plain###JMS Connector Container Application: sap.com/LeistungserfassungEar factory name: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A35478900440000002D0000033C0003E5E9B30C13E9#1097216853238#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###Factory: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A3547890036000000010000033C0003E5E9B4B6C830#1097216885804#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#sap.com/LeistungserfassungEar#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#Guest#2####369d536018f311d9ae2600028a354789#SAPEngine_Application_Thread[impl:3]_39##0#0#Debug#1#/System/Database#Plain###exportMonatsabschlussToSap#

Former Member
0 Kudos

Hi *,

to solve my problem I created another application. Now I got following exceptions:

#1.5#00028A354789003D0000003300000E880003E5EE897F3126#1097237668632#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#546####9a3a92e0192311d998e200028a354789#SAPEngine_Application_Thread[impl:3]_1##0#0#Error##Plain###Factory: myMdbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A35478900530000000100000E880003E5EE89815945#1097237668772#com.sap.jms##com.sap.jms.server.sessioncontainer.InboundBus instance=default#Administrator#546####9a517640192311d98d5200028a354789#SAPEngine_Application_Thread[impl:3]_14##0#0#Error##Plain###com.sap.jms.server.exception.JMSServerException: The requested destination myMdbQueue is not a queue.

at com.sap.jms.server.service.impl.RegistryServiceImpl.createDestinationContext(RegistryServiceImpl.java:231)

at com.sap.jms.server.sessioncontainer.handler.DestinationHandler.onCreateRequest(DestinationHandler.java:134)

at com.sap.jms.server.sessioncontainer.handler.DestinationHandler.process(DestinationHandler.java:71)

at com.sap.jms.server.sessioncontainer.InboundBus.process(InboundBus.java:143)

at com.sap.jms.server.sessioncontainer.InboundBus.enqueue(InboundBus.java:116)

at com.sap.jms.server.sessioncontainer.SessionContainer.receiveFromDispatcher(SessionContainer.java:63)

at com.sap.jms.server.routingcontainer.RoutingContainer.receiveFromDispatcher(RoutingContainer.java:332)

at com.sap.jms.server.JMSServerContainer.dispatchRequest(JMSServerContainer.java:462)

at com.sap.jms.server.ServerClientAdapter.run(ServerClientAdapter.java:287)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

#

#1.5#00028A354789003D0000003500000E880003E5EE89816993#1097237668772#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#546####9a3a92e0192311d998e200028a354789#SAPEngine_Application_Thread[impl:3]_1##0#0#Error#1#/System/Server#Java###JMS Connector Container Application: sap.com/MyMdbEar destination name: myMdbQueue jms provider error:

[EXCEPTION]

#1#javax.jms.JMSException: The requested destination myMdbQueue is not a queue.

at com.sap.jms.protocol.notification.ServerExceptionResponse.getException(ServerExceptionResponse.java:271)

at com.sap.jms.client.session.Session.checkReceivedPacket(Session.java:1767)

at com.sap.jms.client.session.Session.createQueue(Session.java:1644)

at com.sap.engine.services.jmsconnector.deploy.ContainerImpl.loadDestination(ContainerImpl.java:1833)

at com.sap.engine.services.jmsconnector.deploy.ContainerImpl.prepareStart(ContainerImpl.java:721)

at com.sap.engine.services.deploy.server.application.StartTransaction.prepare(StartTransaction.java:357)

at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:299)

at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesImpl(ParallelAdapter.java:303)

at com.sap.engine.services.deploy.server.application.ParallelAdapter.runInTheSameThread(ParallelAdapter.java:112)

at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesAndWait(ParallelAdapter.java:214)

at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4601)

at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4508)

at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4481)

at com.sap.engine.services.deploy.server.DeployServiceImplp4_Skel.dispatch(DeployServiceImplp4_Skel.java:1163)

at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:292)

at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:183)

at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:118)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

#

Do you now, why SAP Web AS couldn't create the queue?

When I use a predefined queue (sapDemoQueue) it works!

Thanks,

Juergen

Former Member
0 Kudos

Hello,

now I find an error:

#1.5#00028A35478900440000002C0000033C0003E5E9B30AD977#1097216853157#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error#1#/System/Server#Plain###JMS Connector Container Application: sap.com/LeistungserfassungEar factory name: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A35478900440000002D0000033C0003E5E9B30C13E9#1097216853238#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###Factory: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#

#1.5#00028A3547890036000000010000033C0003E5E9B4B6C830#1097216885804#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#sap.com/LeistungserfassungEar#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#Guest#2####369d536018f311d9ae2600028a354789#SAPEngine_Application_Thread[impl:3]_39##0#0#Debug#1#/System/Database#Plain###exportMonatsabschlussToSap#