-
1. Re: JMS MDB (Message Driven Bean)
peterj Jun 17, 2010 12:10 AM (in response to tnguyen_75)Hoiw about this:
http://docs.jboss.org/jbossmessaging/docs/userguide-1.4.5.GA/html/examples.html
You will need to download JBoss Messaging to get the examples, but you do not need to install it - JBoss AS 5.x comes with JBoss Messaging already installed.
I also have another resource, but it is not free. I can provide a URL if you are interested.
-
2. Re: JMS MDB (Message Driven Bean)
tnguyen_75 Jun 17, 2010 11:21 AM (in response to peterj)Thanks for the link. It's very helpful.
However, I ran into a problem when I deploy the MDB ear file to Jboss. I got the following message:
Failed to create Resource SimpleMessageApp.ear - cause: java.lang.RuntimeException:org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): *** DEPLOYMENTS IN ERROR: Name -> Error vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/SimpleMessageApp.ear/ -> org.jboss.deployers.spi.DeploymentException: Could not deploy vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/SimpleMessageApp.ear/app-client-ic.jar/ DEPLOYMENTS IN ERROR: Deployment "vfszip:/C:/jboss-5.1.0.GA/server/default/deploy/SimpleMessageApp.ear/" is in error due to the following reason(s): java.lang.RuntimeException: message-destination has no jndi-name/resolved-jndi-name MessageDestinationReferenceMetaData{name=jms/QueueName,type=javax.jms.Queue,link=ejb-jar-ic.jar#PhysicalQueue,ignore-dependecy=false,jndi-name=null,resolvoed-jndi-
Do you have any idea? (i'm not using EJB 3, just regular EJB)
Here's the code of my SimpleMessageBean:
public class SimpleMessageBean implements MessageDrivenBean, MessageListener {static final Logger logger = Logger.getLogger("SimpleMessageBean");private transient MessageDrivenContext mdc = null;private Context context;public SimpleMessageBean() {logger.info("In SimpleMessageBean.SimpleMessageBean()");}public void setMessageDrivenContext(MessageDrivenContext mdc) {logger.info("In SimpleMessageBean.setMessageDrivenContext()");this.mdc = mdc;}public void ejbCreate() {logger.info("In SimpleMessageBean.ejbCreate()");}public void onMessage(Message inMessage) {TextMessage msg = null;try {if (inMessage instanceof TextMessage) {msg = (TextMessage) inMessage;logger.info("MESSAGE BEAN: Message received: " + msg.getText());} else {logger.warning("Message of wrong type: " +inMessage.getClass().getName());}} catch (JMSException e) {e.printStackTrace();mdc.setRollbackOnly();} catch (Throwable te) {te.printStackTrace();}} // onMessagepublic void ejbRemove() {logger.info("In SimpleMessageBean.remove()");}} // classThanks a bunch!
Tuan
-
3. Re: JMS MDB (Message Driven Bean)
wolfgangknauf Jun 18, 2010 5:14 AM (in response to tnguyen_75)Hi,
I assume that your post at http://community.jboss.org/thread/153262?tstart=0 contains further information about your configuration?
Anyway: if you use annotations, you bind the queue to a JNDI name by using the attribute "mappedName" of the "@MessageDriven" annotation.
@MessageDriven(
activationConfig =
{
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
},
mappedName = "queue/MessageBeanQueue")Otherwise, you might do this through ejb-jar.xml. Here it is a property of "activation-config".
I am just wondering why my sample one time uses two different approaches to do this mapping, but both seemed to work ;-)
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<display-name>MessageEJB</display-name>
<enterprise-beans>
<message-driven>
<display-name>MessageBean</display-name>
<ejb-name>MessageBean</ejb-name>
<ejb-class>...MessageBean</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>queue/MessageBeanQueue</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>Best regards
Wolfgang
-
4. Re: JMS MDB (Message Driven Bean)
tnguyen_75 Jun 18, 2010 5:41 PM (in response to wolfgangknauf)Hi,
Thanks!
It worked.
Tuan
-
5. Re: JMS MDB (Message Driven Bean)
bimaljh Feb 24, 2013 3:47 AM (in response to tnguyen_75)Hi where do you find the MDB.ear file and how you deployed it in JBoss AS7.x.
Please help me out.
I have configured ActiveMQ using the below article by Jiri Pechanec
Integration of JBoss AS 7 with ActiveMQ
-
6. Re: JMS MDB (Message Driven Bean)
wolfgangknauf Feb 24, 2013 2:00 PM (in response to bimaljh)Hi,
this "MDB.ear" will probably not help because it was for JBoss 5 ;-).
So you will have to build your message driven bean yourself, e.g. by following the snippets in the "Integration ... with ActiveMQ" sample.
Best regards
Wolfgang