日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

在JBOSS中开发SESSIONBEAN和MSGBEAN

發布時間:2025/3/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在JBOSS中开发SESSIONBEAN和MSGBEAN 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

JBOSS中開發SESSIONBEANMSGBEAN

?

做法:

JBOSS中,JMS連接工廠的JNDI名:

private static final java.lang.String DESTINATION_JNDI_NAME="queue/testQueue";

private static final java.lang.String CONNECTION_FACTORY_JNDI_NAME="java:JmsXA";

?

Queue q = MsbUtil.getQueue();

QueueConnection conn = MsbUtil.getQueueConnection();

Session ssion = conn.createQueueSession(true,1);

TextMessage msg = ssion.createTextMessage(str);

MessageProducer proc = ssion.createProducer(q);

proc.send(msg);

ssion.close();

?

public static javax.jms.Queue getQueue() throws javax.naming.NamingException

?? {

????? if (cachedQueue == null) {

???????? // Obtain initial context

???????? javax.naming.InitialContext initialContext = new javax.naming.InitialContext();

???????? try {

??????????? java.lang.Object objRef = initialContext.lookup(DESTINATION_JNDI_NAME);

??????????? cachedQueue = (javax.jms.Queue) objRef;

???????? } finally {

??????????? initialContext.close();

???????? }

????? }

????? return cachedQueue;

?? }

?

?

public static javax.jms.QueueConnection getQueueConnection() throws javax.naming.NamingException, javax.jms.JMSException

?? {

?? ? ??

?? ? ??//SpyConnectionFactory conn = new SpyConnectionFactory();

????? if (cachedConnectionFactory == null) {

???????? // Obtain initial context

???????? javax.naming.InitialContext initialContext = new javax.naming.InitialContext();

???????? try {

??????????? java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);

??????????? cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;

????? ???} finally {

??????????? initialContext.close();

???????? }

????? }

????? return cachedConnectionFactory.createQueueConnection();

?? }

?

?

MDB配置:

Ebj-jar.xml

<?xml version="1.0" encoding="UTF-8"?>

?

<!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 >

?

?? <description><![CDATA[No Description.]]></description>

?? <display-name>Generated by XDoclet</display-name>

?

?? <enterprise-beans>

?

????? <!-- Session Beans -->

???? <!--

?????? To add session beans that you have deployment descriptor info for, add

?????? a file to your XDoclet merge directory called session-beans.xml that contains

?????? the <session></session> markup for those beans.

???? -->

?

????? <!-- Entity Beans -->

???? <!--

?????? To add entity beans that you have deployment descriptor info for, add

?????? a file to your XDoclet merge directory called entity-beans.xml that contains

?????? the <entity></entity> markup for those beans.

???? -->

?

????? <!-- Message Driven Beans -->

????? <message-driven >

???????? <description><![CDATA[Msb]]></description>

???????? <display-name>MsgBean</display-name>

?? ??????<ejb-name>MsgBean</ejb-name>

???????? <ejb-class>com.mudboy.msg.ejb.MsbBean</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>

????? </message-driven>

?

???? <!--

?????? To add message driven beans that you have deployment descriptor info for, add

?????? a file to your XDoclet merge directory called message-driven-beans.xml that contains

?????? the <message-driven></message-driven> markup for those beans.

???? -->

?

?? </enterprise-beans>

?

?? <!-- Relationships -->

?

?? <!-- Assembly Descriptor -->

???? <!--

?????? To specify your own assembly descriptor info here, add a file to your

?????? XDoclet merge directory called assembly-descriptor.xml that contains

?????? the <assembly-descriptor></assembly-descriptor> markup.

???? -->

?

?? <assembly-descriptor >

???? <!--

?????? To specify additional security-role elements, add a file in the merge

?????? directory called ejb-security-roles.xml that contains them.

???? -->

?

?? <!-- method permissions -->

???? <!--

?????? To specify additional method-permission elements, add a file in the merge

? ?????directory called ejb-method-permissions.ent that contains them.

???? -->

?

?? <!-- finder permissions -->

?

?? <!-- transactions -->

???? <!--

?????? To specify additional container-transaction elements, add a file in the merge

?????? directory called ejb-container-transaction.ent that contains them.

???? -->

?

?? <!-- finder transactions -->

?

???? <!--

?????? To specify an exclude-list element, add a file in the merge directory

?????? called ejb-exclude-list.xml that contains it.

???? -->

?? </assembly-descriptor>

?

</ejb-jar>

?

Jboss.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

<jboss>

? <enterprise-beans>

??? <message-driven>

????? <ejb-name>MsgBean</ejb-name>

????? <destination-jndi-name>queue/testQueue</destination-jndi-name>

????? <configuration-name>Standard Message Driven Bean</configuration-name>

??? </message-driven>

? </enterprise-beans>

</jboss>

?

?

MyEclipse開發還是很容易的。

?

總結

以上是生活随笔為你收集整理的在JBOSS中开发SESSIONBEAN和MSGBEAN的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。