jboss ejb3 Message Driven Bean

sponsored links
Super Medium ejb hate. . . . . . . . . . . . . . . . . . .

================================================

To configure a Message Driven Bean in a different application server parameters are not the same.

Currently only passed the test jboss.

Message Driven Bean part 2 contains a configuration file and a java category. (The book that it does not need configuration files can also be, I have not been successful, with a total reported is not found in the veryDepressed .)

1.java category.

/*
 * File name: MessageBean .java
 * 
 * Creation date: 2009 -2-26
 *
 * Copyright(C) 2009, by Ryoma.
 *
 * The original author : <a href="mailto:lemom8000@gmail.com">Ryoma</a>
 *
 */
package com.mdb.ejb.impl;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;

/**
 * 
 * 
 * @author <a href="mailto:lemom8000@gmail.com">Ryoma</a>
 * 
 * @version $Revision$
 * 
 * @since 2009-2-26
 */
@MessageDriven(activationConfig =
	{

			@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

			@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/myQueue")

	})
public class MessageBean implements MessageListener {

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
	 */
	public void onMessage(Message message) {
		System.out.println("MessageBean:" + message.getClass());
		System.out.println("MessageBean:" + message);
	}

}

Red part of the application in different not the same. MessageListener are to be achieved. Yellow myQueue necessary configuration in the configuration file.

2. Configuration file. xxxxx-service.xml under deploy or him on the following directory.

<mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=myQueue">
		<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>
<mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=PrivateDLQ"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>

Can be two ways, first is to find online, the second is on the server in the example-destinations-service.xml found. The second in the document has much writing, the specific property do not know what did not used to find documents, has found give me a hair lemom8000@gmail.com

================================================== =========

Call the following methods:

<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="javax.naming.*, java.text.*, javax.jms.*, java.util.Properties"%>
<%
    QueueConnection cnn = null;
    QueueSender sender = null;
    QueueSession sess = null;
    Queue queue = null;

    try {
			Properties props = new Properties();
			props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
			props.setProperty("java.naming.provider.url", "localhost:1099");
			props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");	
      InitialContext ctx = new InitialContext(props);
      QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
      cnn = factory.createQueueConnection();
      sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
			queue = (Queue) ctx.lookup("queue/myQueue");
    } catch (Exception e) {
		out.println(e.getMessage());
    }
	try {
		TextMessage msg = sess.createTextMessage("This is my first message driven bean ");
		sender = sess.createSender(queue);
		sender.send(msg);
		sess.close ();
		out.println("The message was sent out, you can to JBoss console to view the output of the Bean ");
	} catch (Exception e) {
		out.println(e.getMessage());
	}
		
%>


Internet to find examples, test passed.

================================================== =====

EJB good use again quickly. . . . . . . . . . . .
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of jboss ejb3 Message Driven Bean

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • myeclipse plugin

    myeclipsePlug-ins? 1.tomcatPlugin(Start tomcat ):http ://www.sysdeo.com/eclipse/tomcatPlugin.html,2.xVersions of eclipse 3 version 2 .1Version doesn't work. 2.Lomboz(Development of jsp program ,jspDynamic prompt, debugging ):http://forge.objectweb.org/pro

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • First Hibernate Example

    Curd a simple example. Source does not contain the dependent libraries, or playing too much of the package. PO object Note: One must have the default constructor 2 non-final modified. Otherwise useless lazy loading. UserDAOImpl category code, and other co

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries