we are implemeting an MDB EJB Bean( testEJBBean.java).But we are not able to generate any EJB files.We also made an test client for it(testMDBClient.java) and another Stateless bean (SupplierEJBBean).
Wat we are actually trying to do is that ..our test client (testMDBClient.java) will send data and MDB EJB Bean(testEJBBean.java) will recieve it and pass it to Stateless bean(SupplierEJBBean).
We already made statefull and stateless bean and they were successfuly generating EJB files and also deployed it but MDB we were unable to do it. We have tried very hard to find it but we were unable to find it..plz help us as we are at the end of completing our project
here are our files... very simple test program. MDB EJB Bean( testEJBBean.java) /* * Created on Mar 30, 2005 */ package temp.mdb.bean;
private InitialContext getContext() throws NamingException { Hashtable props = new Hashtable(); props.put( InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099"); InitialContext initialContext = new InitialContext(props); return initialContext; } /** Required method for container to set context. */ public void setMessageDrivenContext( javax.ejb.MessageDrivenContext messageContext) throws javax.ejb.EJBException { this.messageContext = messageContext; } /** * Required creation method for message-driven beans. * * @ejb.create-method */ public void ejbCreate() { // no specific action required for message-driven beans }
/** Required removal method for message-driven beans. */ public void ejbRemove() { messageContext = null; }
/** * This method implements the business logic for the EJB. * *
Make sure that the business logic accounts for asynchronous message processing. * For example, it cannot be assumed that the EJB receives messages in the order they were * sent by the client. Instance pooling within the container means that messages are not * received or processed in a sequential order, although individual onMessage() calls to * a given message-driven bean instance are serialized. * *
The onMessage() method is required, and must take a single parameter * of type javax.jms.Message. The throws clause (if used) must not include an application * exception. Must not be declared as final or static. */ public void onMessage(javax.jms.Message message) { System.out.println("Message Driven Bean got message " + message);
try { RequestItem ri = (RequestItem) ((ObjectMessage) message).getObject(); if (message instanceof ObjectMessage) {
System.out.println("Showing Replenished item and qauntity"); System.out.println("Item ID :" + ri.getItemID()); System.out.println("Quantity :" + ri.getQuantity());
public static void testMDBBEAN() { RequestItem ri = new RequestItem("abc",12); try { System.out.println("Looking up the factory"); InitialContext ctx = getContext(); QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup
("ConnectionFactory");
System.out.println("Looking up the Queue"); Queue queue = (Queue) ctx.lookup("queue/MdbQueue");
System.out.println("Creating the Connection now"); QueueConnection connection = factory.createQueueConnection
();
System.out.println("Creating the Session now"); QueueSession session = connection.createQueueSession(true,1);
Not sure if I understand you right, but from what I�ve been reading looks like your problem is that you cannot generate the deployment descriptors for your MDB. We�re using WebLogic and we specify the bean-type as well within the ejb.bean tag (although this is not documented):
See if this helps. By the way, you might like considering CMT with your MDB. One disadvantage of using BMT is that if your transaction rolls back, you application cannot cause the message to remain to the original destination. Regards.
I think, therefore I exist -- Rene Descartes
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.