Skip to Content
author's profile photo Former Member
Former Member

How to configure Queue and QueueConnectionFactory for a MDB

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2004 at 03:21 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Vesselin Mitrov

      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

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2004 at 06:33 AM

    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#

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2004 at 12:46 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 09, 2004 at 12:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.