Using Message Driven bean in JDev 9.0.3.2
Hi all,
I'm trying to create a Message bean in JDeveloper 9.0.3.2. I've used the wizard which has (very nicely) created me the bean files, i have also set up OC4J server and deployed to it and it seems to run fine.
Now, i'm trying to create a class (in the same project) that sends a message to the bean but i'm having problems. Session beans in JDev have a very nice option to create a Sample Java Client but there is no equivalent "Sample Message Creator" for message beans.
Anyway, my code is as follows...
Context ctx = new InitialContext();
TopicConnectionFactory factory = (TopicConnectionFactory)ctx.lookup("javax.jms.TopicConnectionFactory");
....more code to create and send message
However, i don't know where to lookup the factory from, this line gives me an error presumably because javax.jms.TopicConnectionFactory is incorrect. What is the Oracle lookup for this ? Where do i find it out from ?
Any advice would be appreciated, sorry this is not a posting on 10g which i haven't had chance to look at yet (though i hear it's very nice).
Alistair
You might find the sample code which is part of OC4J-howto's useful.
http://otn.oracle.com/tech/java/oc4j/904/index.html
http://otn.oracle.com/tech/java/oc4j/904/how_to/how-to-ejb-mdb.zip
raghu
JDev Team
Similar Messages
-
Messenger service using message driven beans
I need to implement a implement a messenger service. (using Messaging server, Message Queue, Message Clients and Message Driven Beans)
using netbeans 5.5
it should develop using EJB 3.0 architeture.
Can pls tell...how should i start this.(Basic steps of doing this)
Where should we write the Messaging server.(in a EJB 3.0 application...Is it?)
Any tutorial regrading this....!EJBs and Message Driven Part.
what should i develop first. Messaging server OR Message Queue
How can i develop the Messaging Server. Do i need to use Message driven beans there?
Message was edited by:
jugp -
Distributed Garbage Collector (DGC) messages in cluster when using Message Driven Beans
Version: Weblogic 6.1 SP2
I'm seeing a lot of messages output on the node ** hosting my JMS
server/destination ** in the cluster
<Jun 4, 2002 5:35:03 PM EDT> <Info> <DGCserver> <Tried to renew lease on
lost reference: '448'>
Unfortunately, this message coincides with my MDB's ** on other nodes ** not
being able to lookup the JMS destination that they are configured for.
MDB's on the same node as the JMS server/destination are able to do lookups
fine.
Checking the JNDI tree on all nodes, I see the destinations replicated to
all nodes. The MDB's use the default (i.e WebLogic's) connection factory
(weblogic.jms.MessageDrivenBeanConnectionFactory) and I've bumped up the
polling interval to 5 minutes from the default of 10 seconds.
Any guidance on this would be greatly appreciated.
I see that there is a patch available to fix the DCC info messages (April
,2002) on dev2dev. Anyone know if this addresses the MDB problem?
Thanks in advance
FYI - in case anyone else sees this problem - it has been fixed in WLS 6.1
SP3.
If you are seeing this problem then you will see a log of
NoSuchObjectException's in your console.
Regards
"Prashant Nayak" <[email protected]> wrote in message
news:[email protected]...
> Version: Weblogic 6.1 SP2
>
> I'm seeing a lot of messages output on the node ** hosting my JMS
> server/destination ** in the cluster
>
> <Jun 4, 2002 5:35:03 PM EDT> <Info> <DGCserver> <Tried to renew lease on
> lost reference: '448'>
>
> Unfortunately, this message coincides with my MDB's ** on other nodes **
not
> being able to lookup the JMS destination that they are configured for.
> MDB's on the same node as the JMS server/destination are able to do
lookups
> fine.
>
> Checking the JNDI tree on all nodes, I see the destinations replicated to
> all nodes. The MDB's use the default (i.e WebLogic's) connection factory
> (weblogic.jms.MessageDrivenBeanConnectionFactory) and I've bumped up the
> polling interval to 5 minutes from the default of 10 seconds.
>
> Any guidance on this would be greatly appreciated.
>
> I see that there is a patch available to fix the DCC info messages (April
> ,2002) on dev2dev. Anyone know if this addresses the MDB problem?
>
> Thanks in advance
>
>
>
>
>
-
WebLogic hangs around after shutdown process appears to complete - Message Driven Bean related
On my current project we have some Ant scripts that automatically
start and stop WebLogic. The stop script equates to (not exactly but
close enough):
java weblogic.Admin -url localhost:8001 -password password -username
username SHUTDOWN
WebLogic is start and shutdown for each system module. All modules
use the exact same script for these two actions. Some of the modules
use Message Driven Beans and consequently, since these use JMS, a
JMSxxx.dat file is generated in the jms_store directory. As part of
the cleanup process the jms_store directory and all files in it are to
be deleted AFTER WebLogic shuts down.
The shutdown process works fine in all cases where JMS is not used and
in all cases where JMS IS used but there are NO message driven beans.
However, when there is a message driven bean the server does not shut
down in a timely manner, sometimes not at all (no error messages are
produced), and the JMSxx.dat file
remains locked. Consequently, all of the tests run via the ant script
for modules come to a grinding halt (i.e. environment could not be
cleaned so further tests would be skewed).
Can anyone shed some light on a definitive order of events during
WebLogic's shutdown process? What is the best way to test for the
server being up? I know there is a ping utility for weblogic - should
this be used or should a connection to a JNDI or JMS listening port do
the trick? Any other ideas would be welcome.
Thanks in advance,
MarkOn my current project we have some Ant scripts that automatically
start and stop WebLogic. The stop script equates to (not exactly but
close enough):
java weblogic.Admin -url localhost:8001 -password password -username
username SHUTDOWN
WebLogic is start and shutdown for each system module. All modules
use the exact same script for these two actions. Some of the modules
use Message Driven Beans and consequently, since these use JMS, a
JMSxxx.dat file is generated in the jms_store directory. As part of
the cleanup process the jms_store directory and all files in it are to
be deleted AFTER WebLogic shuts down.
The shutdown process works fine in all cases where JMS is not used and
in all cases where JMS IS used but there are NO message driven beans.
However, when there is a message driven bean the server does not shut
down in a timely manner, sometimes not at all (no error messages are
produced), and the JMSxx.dat file
remains locked. Consequently, all of the tests run via the ant script
for modules come to a grinding halt (i.e. environment could not be
cleaned so further tests would be skewed).
Can anyone shed some light on a definitive order of events during
WebLogic's shutdown process? What is the best way to test for the
server being up? I know there is a ping utility for weblogic - should
this be used or should a connection to a JNDI or JMS listening port do
the trick? Any other ideas would be welcome.
Thanks in advance,
Mark -
Need to Parse XML Message from my Message Driven Bean
Hi
I am using Message Driven Beans for listening to a Queue .
I am getting a Big XML file from my Queue in form of a TextMessage .
Now my task is to read / parse the XML Message .
Please tell me what is the appropiate parsing technique i need to use (Should i use SAX or DOM )
Please share your ideas .
Thank you .Generally you want to use SAX if the file is so big that loading it all in memory (as DOM does) will create memory problems.
Read about these methods on the wiki page for [JAXP.|http://en.wikipedia.org/wiki/Java_API_for_XML_Processing] -
hi
i have some heavy calculating beans and i want that only one EJB is calculating at one time. can i do this by using Message Driven Beans? is it possible that the server creates only one Message Driven Bean at one time and gets the next one out of the queue when the old one finished calculating?
thanks, joIt is possible to set up that there should be only one mdb in the pool, but it's not quite what mdbs are intended for. Remember that this is an asynchronous message service, and you will not receive a reply after you put a message on the queue.
-
Is Message Driven Beans Supported in iAS 6.5?
Hello Everybody,
Admin guide of iAS 6.5 speaks about using Message driven beans (mdb). It also says that iAS 6.5 supports EJB 1.1 specification. But, EJB 1.1 specification doesnt support mdbs. Only EJB 2.0 does this. Then how come iAS 6.5 supports mdb, when it says that it is EJB 1.1 complaint and not EJB 2.0 complaint.
Please clear this doubt for me.
regards,
desiganIt is me who is posting again.
This is what provided in the Developer guide. I have just read it.
"iPlanet Application Server, Enterprise Edition 6.5, provides support for deploying message-driven beans. This implementation is based on the EJB 2.0 specifications,
and is for developer use only. The message-driven bean infrastructure in this release has not been tested in a production environment."
regards,
desigan -
Transactional onMessage without message driven beans
Hi.
Imagine a system that does not use message driven beans, but instead a non-EJB MessageListener that invokes some SessionBean method in its onMessage(), as described for example in "http://www.theserverside.com/resources/article.jsp?l=Bringing-Together-Application-Servers-and-JMS-Messaging".
Is it possible to execute the MessageListener.onMessage() and the SessionBean.someMethod() in the same transaction, in such a way that the message is not being removed from the queue if processing in the EJB fails? With JMS methods, given the JMS provider is JTA - capable?
Products would be WebSphere 4.0.1 an MQSeries.
Any hints would be appreciated,
thanks,
LutzYes, If the Jms Provider is JTA capable then the OnMessage method can be made transactional.
Go thru XA package of jms specification.
-Ashish -
Problem deploying message driven bean using Log4j
Hello all.
Using JDeveloper 11.1.1.0.2, I'm having a problem with a message driven bean I've created and associated with a JMS queue.
I've created an EJB Module project in my application (in which some other projects exist), and created the bean. A simple test of the bean, sending a message through the jms queue and printing it on system.out in the mdb onMessage() worked just fine.
However, when I add apache commons logging to my mdb, things start to go wrong. Running the project on the integrated weblogic 10.3 server just fails during deployment, due to a NoClassDefFoundError on org/apache/log4j/Logger.
In project properties -> libraries and classpath, I've added a log4j library (Log4j-1.2.14.jar) next to Commons Logging 1.0.4 but it doesn't seem to matter anything.
The code of my message bean:
@MessageDriven(mappedName = "weblogic.wsee.DefaultQueue")
public class MyMessageBean implements MessageListener {
// logger
private static Log sLog = LogFactory.getLog(MyMessageBean.class);
public void ejbCreate() {
public void ejbRemove() {
public void onMessage(Message message) {
MapMessage mapmsg = null;
try {
if (message instanceof MapMessage) {
mapmsg = (MapMessage)message;
boolean msgRedelivered = mapmsg.getJMSRedelivered();
String msgId = mapmsg.getJMSMessageID();
if (!msgRedelivered) {
sLog.debug("****** Successfully received message " + msgId);
} else {
sLog.debug("****** Successfully received redelivered message " + msgId);
// Haal de inhoud op:
int testInt = mapmsg.getInt("TestInt");
sLog.debug("TestInt:" + testInt);
} else {
sLog.debug("Message of wrong type: " +
message.getClass().getName());
} catch (Exception e) {
sLog.error("Fout in verwerken",e);
}Does anybody have any clue as to what I might be doing wrong or missing out here?
The complete stacktrace:
5-aug-2009 12:54:44 oracle.adf.share.config.ADFConfigFactory cleanUpApplicationState
INFO: Cleaning up application state
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processWLSAnnotations(EjbAnnotationProcessor.java:1705)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processWLSAnnotations(EjbDescriptorReaderImpl.java:346)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)
at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1198)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:380)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at nl.justid.dolores.mdb.MyMessageBean.<clinit>(MyMessageBean.java:19)
... 32 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 36 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
... 37 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 42 more
<5-aug-2009 12:54:44 uur CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1249469684085' for task '14'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.'
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
Truncated. see log file for complete stacktrace
>
5-aug-2009 12:54:44 oracle.adf.share.config.ADFConfigFactory cleanUpApplicationState
INFO: Cleaning up application state
<5-aug-2009 12:54:44 uur CEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'Dolores'.>
<5-aug-2009 12:54:44 uur CEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
Truncated. see log file for complete stacktrace
>
[Deployer:149034]An exception occurred for task [Deployer:149026]deploy application Dolores on DefaultServer.: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null..
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
#### Deployment incomplete. #### Aug 5, 2009 12:54:44 PM
oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:247)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:157)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:436)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
at oracle.jdevimpl.runner.adrs.AdrsStarter$5$1.run(AdrsStarter.java:1365)
Caused by: oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:413)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:238)
... 11 more
Caused by: oracle.jdeveloper.deploy.DeployException: Deployment Failed
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:395)
... 12 more
#### Cannot run application Dolores due to error deploying to DefaultServer.
[Application Dolores stopped and undeployed from Server Instance DefaultServer]Thanks in advance!
Greetings,
Eelse
Edited by: Eelse on Aug 5, 2009 1:57 PM
Edited by: Eelse on Aug 5, 2009 5:39 PMCreating a new deployment profile (EAR) and including the original deployment (JAR) and the needed libraries (in a lib-directory) solved the problem.
-
Message-Driven Bean using @Resource annotation
I am trying to run a Message-Driven Bean very simple example in https://glassfish.dev.java.net/javaee5/ejb/examples/MDB.html
I configured MDBQueueConnectionFactory and MDBQueue properly on glassfish admin console.
I cannot run the example using @Resource annotation. I don't understand why.
@Resource(mappedName="MDBQueueConnectionFactory")
private static QueueConnectionFactory queueCF;
@Resource(mappedName="MDBQueue")
private static Queue mdbQueue;But I can run this example modifying the source code using InitialContext instance and looking up for JMS Resources.
InitialContext ctx = new InitialContext();
QueueConnectionFactory queueCF=(QueueConnectionFactory)ctx.lookup("MDBQueueConnectionFactory");
QueueConnection queueCon = queueCF.createQueueConnection();
Queue mdbQueue=(Queue)ctx.lookup("MDB");
queueSender.send(mdbQueue, msg);
...I want to figure out why @Resource annotation do not work well. Any help?
Thanks in advanced any help.Thanks for your reply.
The error that I get is a simple NullPointerException. Nothing else.
Like you said, I develop a servlet and I can use @Resource annotation without static reference, and it works.
public class TestMDB extends HttpServlet {
private static final long serialVersionUID = 1L;
@Resource(mappedName="MDBQueueConnectionFactory")
private QueueConnectionFactory queueCF;
@Resource(mappedName="MDB")
private Queue mdbQueue;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("TEST MDB "+queueCF);
QueueConnection queueCon;
try {
queueCon = queueCF.createQueueConnection();
QueueSession queueSession = queueCon.createQueueSession
(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(null);
TextMessage msg = queueSession.createTextMessage("hello");
queueSender.send(mdbQueue, msg);
out.println("Sent message to MDB");
queueCon.close();
} catch (JMSException e) {
e.printStackTrace();
}But my question were about using @Resource annotation on a standalone client. I always get NullPointerException.
public class MDBClient {
@Resource(mappedName="MDBQueueConnectionFactory")
private static QueueConnectionFactory queueCF;
@Resource(mappedName="MDB")
private static Queue mdbQueue;
public static void main(String args[]) {
try {
QueueConnection queueCon = queueCF.createQueueConnection();
QueueSession queueSession = queueCon.createQueueSession
(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(null);
TextMessage msg = queueSession.createTextMessage("hello");
queueSender.send(mdbQueue, msg);
System.out.println("Sent message to MDB");
queueCon.close();
} catch(Exception e) {
e.printStackTrace();
} -
Message driven beans practical use
Hi,
I wanted to know,where Message driven beans are used in actual commercial projects???
Thanks in advance.Hi,
Without naming any particular projects, i can asure you that MessageDriven Beans are used in commercially deployed systems.
Most important is to recognise the goal of MDBs. Everything inside a J2EE server is Request-Response like. Session and Entity beans react on requests. Because of the life cycle of these types of EJBs waiting for incoming messages is not realy a good idea.
In all cases were asynchronous middleware solutions are used, like MQ series for example, MDBs are used to listen for and react on incoming messages.
Furthermore, MDBs are used to decouple web tier from business tier where processing times of incoming data is too long to wait for by the clients.
Robert -
B2B using JMS and Processing Messages with Message Driven Beans
We want to be able to use B2B to send messages to a JMS queue and then process messages from B2B using a Message Driven Bean. Is this supported.
We are using B2B 10.2.0.2 with Patchset 4.Hello,
In 10.1.2.0.2 B2B , as part of the internal Delivery channel B2B can only send and receive messages from JMS queues.
Rgds,Ramesh -
Message Driven bean: message always removed from queue
We use MDB to dequeue messages from database queue (AQ) and want to handle errors: if the transaction rolls back, message should have retry_count updated and after defined retries should move to exception queue.
The problem is, that with all combinations of transactions settings, the message is removed from queue before onMessage is called. If I use Container managed transactions with Mandatory transaction attribute, call to setRollbackOnly fails with message "java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction."
How can I write a MDB, which can commit or rollback message depending on whether exception is or is not thrown? I use JDev 10.1.3.
Thanks,
Viliam
Here are my files:
ejb-jar.xml:
<?xml version = '1.0' encoding = 'windows-1250'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<description>Message Driven Bean</description>
<display-name>SendSMSBean</display-name>
<ejb-name>SendSMSBean</ejb-name>
<ejb-class>sk.transacty.cc.ejb.SendSMSBeanBean</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<resource-ref>
<res-ref-name>jdbc/CCDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>SendSMSBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Mandatory</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>orion-ejb-jar.xml:
<?xml version = '1.0' encoding = 'windows-1250'?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar>
<enterprise-beans>
<message-driven-deployment max-instances="1" name="SendSMSBean" connection-factory-location="java:comp/resource/jmsAQ/QueueConnectionFactories/aqQue" destination-location="java:comp/resource/jmsAQ/Queues/msg_queue" listener-threads="1" min-instances="0"/>
</enterprise-beans>
<assembly-descriptor>
<default-method-access>
<security-role-mapping impliesAll="true" name="<default-ejb-caller-role>"/>
</default-method-access>
</assembly-descriptor>
</orion-ejb-jar>As far as I know XMLType JMS messages are not supported when using OJMS. They might be for OC4J 10.1.3, but I thought it's an AQ limitation rather than an OC4J one.. To be sure you might just log a TAR on Metalink.
hth,
Bastiaan -
Message Driven Bean debugging not supported in 9.0.3?
Message Driven Beans are now supported with the preview of 9.0.3, but you can't debug into them using the embedded container? Will this be resolved for the release version?
Brice --
Are you using the embedded help system or hosted documentation? I've just double-checked, and with the full jdev install, the "About Debugging PL/SQL Programs and Java Stored Procedures" is loading fine for me.
The PL/SQL variable should show up as well, without anything needing to be enabled on the server. What database version are you using, and what are the datatypes of the PL/SQL variables?
-- Brian
Hello,
We have downloaded JDev 903 Preview to try out the new PL/SQL debugging features, but it seems we are unable to inspect/watch/debug PL/SQL variables. The relevant panels are simply blank.
Strangely enough, the help files are also lacking on the subject (e.g. the "About debugging PL/SQL" help topic does not seem to exist).
Is there an option to turn on in the database server to view PL/SQL variables ?
Thanks
Regards
Brice -
How to transaction in the message driven bean?
hello
i write a message driven bean,that monitor the weblogic message queue,when a "Order"
object is witten to the queue,the mdb get it and write it to a entity bean "Orderinfo".all
of above logic is within the "onMessage" method of the mdb.
i want to encapsulate the flow in a transaction,see my code snippet of the onMessage
method:
ObjectMessage objMsg = (ObjectMessage) msg;
OrderVO orderVO = (OrderVO) objMsg.getObject();
System.out.println(orderVO.booklist);
OrderinfoHome orderinfoHome = (OrderinfoHome) ctx.lookup(
"java:/comp/env/orderinfo");
Orderinfo orderinfo = orderinfoHome.create(orderVO.orderID);
orderinfo.setAddress(orderVO.address);
orderinfo.setCustname(orderVO.custName);
orderinfo.setEmail(orderVO.email);
orderinfo.setBooklist(orderVO.booklist);
orderinfo.setPrice(new BigDecimal(orderVO.price));
and deploy descriptor snippet(ejb-jar.xml):
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>orderMDB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
i think during this transaction,there are two action:geting the object from the
queue and saving it to entity bean.in order to test the transaction,i modify the
jndi name of entity bean in the code to a WRONG one.redeploy my program,and send
a message to the queue,the mdb is activated,then the exception is thrown because
of the wrong jndi name.after that,i check the message queue,find that it is empty.why?i
think if the second action of the transaction is fail,the transaction should roll
back,the message should be send BACK to the queue.
i also ty to use the "javax.transaction.UserTransaction" in the onMessage method,but
the follwing exception is thrown:
javax.transaction.NotSupportedException: Another transaction is associated with
this thread.................................
who can help me,if any wrong with me,and how to use the transaction with the message
driven bean?
thank you.
The transaction should rollback if the MDB throws an
exception. Try changing your MDB code to
call "setRollbackOnly()" on the EJB
context (instead of throwing an exception) to see
if that works. If calling "setRollbackOnly()" fixes
the problem - then please contact customer support
and report a bug.
zbcong wrote:
> hello
>
> i write a message driven bean,that monitor the weblogic message queue,when a "Order"
> object is witten to the queue,the mdb get it and write it to a entity bean "Orderinfo".all
> of above logic is within the "onMessage" method of the mdb.
> i want to encapsulate the flow in a transaction,see my code snippet of the onMessage
> method:
>
>
> ObjectMessage objMsg = (ObjectMessage) msg;
> OrderVO orderVO = (OrderVO) objMsg.getObject();
> System.out.println(orderVO.booklist);
> OrderinfoHome orderinfoHome = (OrderinfoHome) ctx.lookup(
> "java:/comp/env/orderinfo");
> Orderinfo orderinfo = orderinfoHome.create(orderVO.orderID);
> orderinfo.setAddress(orderVO.address);
> orderinfo.setCustname(orderVO.custName);
> orderinfo.setEmail(orderVO.email);
> orderinfo.setBooklist(orderVO.booklist);
> orderinfo.setPrice(new BigDecimal(orderVO.price));
>
>
> and deploy descriptor snippet(ejb-jar.xml):
>
>
> <assembly-descriptor>
> ............
> ...........
>
> <container-transaction>
> <method>
> <ejb-name>orderMDB</ejb-name>
> <method-name>*</method-name>
> </method>
> <trans-attribute>Required</trans-attribute>
> </container-transaction>
> </assembly-descriptor>
>
>
> i think during this transaction,there are two action:geting the object from the
> queue and saving it to entity bean.in order to test the transaction,i modify the
> jndi name of entity bean in the code to a WRONG one.redeploy my program,and send
> a message to the queue,the mdb is activated,then the exception is thrown because
> of the wrong jndi name.after that,i check the message queue,find that it is empty.why?i
> think if the second action of the transaction is fail,the transaction should roll
> back,the message should be send BACK to the queue.
>
> i also ty to use the "javax.transaction.UserTransaction" in the onMessage method,but
> the follwing exception is thrown:
>
> javax.transaction.NotSupportedException: Another transaction is associated with
> this thread.................................
>
> who can help me,if any wrong with me,and how to use the transaction with the message
> driven bean?
>
> thank you.
>
>
Maybe you are looking for
-
Help in ABAP function module coding.
Hi, i am having trouble coding the program where i have to select a number from the table and add one to it to create a new record back to the table. example, i've select 1 from the table, i need the program to be able to return 2 and create a new r
-
The top left of previous Firefox versions had the left arrow key to go back to the previous web page and a button that would list all the previous web pages so that I could select, say, the 5th previous page. I can't find this button on Firefox 4. Is
-
Merging two company codes at sales organization levels
Hello Guru's, I am working on a complex project, the client wants to merge two company codes at sales organization level. Will anyone guide me the procedure to do it. Regards, PV
-
Unable to create a seed of 8 bytes.
Hi all, This is the list of providers in my "java.security" file security.provider.1=com.rsa.jsafe.provider.JsafeJCE security.provider.2=sun.security.provider.Sun security.provider.3=com.sun.net.ssl.internal.ssl.Provider security.provider.4=com.sun.c
-
Hi All, I have two scenarios. 1. IDOC to File 2.File to IDOC. My requirement is to get the acknowledgement in both the cases. 1. Scenario (IDOC to File) I have ALEAUD message type for Source and user defined message type for target. 2. Scenario (Fi