ejb 2.1 jboss

Please go through my previous posts to understand some JMS Concepts and JMS 1.1 API Basics. In this post, we are going to discuss on “How to develop JMS 1.1 Producer and Consumer Example With Eclipse IDE and JBoss 6.0 Application Server”.

请阅读我以前的文章,以了解一些JMS概念和JMS 1.1 API基础。 在本文中,我们将讨论“如何使用Eclipse IDE和JBoss 6.0 Application Server开发JMS 1.1生产者和使用者示例”。

发表简短目录 (Post Brief TOC)

  • Introduction
    介绍
  • Steps to Configure JBoss 6.0 AS In Eclipse IDE
    在Eclipse IDE中配置JBoss 6.0 AS的步骤
  • Create Eclipse EJB Project And Configure Queue
    创建Eclipse EJB项目并配置队列
  • Develop The Producer and Consumer Programs
    制定生产者和消费者计划
  • Run and Observe The results
    运行并观察结果

介绍 (Introduction)

In my previous example at “JMS 1.1 With Embedded JBoss HornetQ Server Example”, we have developed JMS 1.1 Producer and Consumer in a single program and also used Embedded Server.

在我之前的示例“带有嵌入式JBoss HornetQ Server示例的 JMS 1.1 ”中 ,我们已经在单个程序中开发了JMS 1.1生产者和使用者,并且还使用了嵌入式服务器。

Now, we are going to develop similar kind of example, but with two separate programs: one for Producer and another for Consumer. We use JBoss 6.0 Application Server as JMS Server.

现在,我们将开发类似的示例,但有两个单独的程序:一个针对生产者,另一个针对消费者。 我们使用JBoss 6.0 Application Server作为JMS Server。

JBoss AS (Application Server) is an open source application server from Red Hot for developing and deploying Enterprise Java applications, Web applications and services, and portals. By default, JBoss AS uses HornetQ as JMS Provider. HornetQ is an open source JMS Provider for building multi-protocol, embeddable, very high performance, clustered and asynchronous messaging systems.

JBoss AS(应用程序服务器)是Red Hot提供的开源应用程序服务器,用于开发和部署企业Java应用程序,Web应用程序和服务以及门户。 默认情况下,JBoss AS使用HornetQ作为JMS Provider。 HornetQ是一个开源JMS Provider,用于构建多协议,可嵌入,非常高性能的集群和异步消息传递系统。

In this post, we’re going to develop JMS 1.1 Application with JBoss AS V.6.x in Eclipse IDE.

在本文中,我们将在Eclipse IDE中使用JBoss AS V.6.x开发JMS 1.1应用程序。

在Eclipse IDE中配置JBoss 6.0 AS的步骤 (Steps to Configure JBoss 6.0 AS In Eclipse IDE)

  • Download JBoss AS from https://www.jboss.org/jbossas/downloads/ as zip file.
    从https://www.jboss.org/jbossas/downloads/下载JBoss AS压缩文件。
  • Extract jboss-6.0.0.Final.zip file into local file system.
    将jboss-6.0.0.Final.zip文件解压缩到本地文件系统中。
  • Create JBoss AS in Eclipse IDE.
    在Eclipse IDE中创建JBoss AS。
  • Click on “Create a new server” link to open “New Server” Window

    单击“创建新服务器”链接以打开“新服务器”窗口

    Select “JBoss AS 6.x” and Click on “Next” button. Select JBoss 6.x Path from your local file system. Select “Default” Configuration and click on “Finish” Button

    选择“ JBoss AS 6.x”,然后单击“下一步”按钮。 从本地文件系统中选择JBoss 6.x Path。 选择“默认”配置,然后单击“完成”按钮

    Now we can observe newly created server in Eclipse IDE

    现在我们可以在Eclipse IDE中观察新创建的服务器

  • Start JBoss 6.x AS in Eclipse IDE.
    在Eclipse IDE中启动JBoss 6.x AS。
  • Now we can observe JBoss 6.x AS is up and running

    现在我们可以观察到JBoss 6.x AS已启动并正在运行

创建Eclipse EJB项目并配置队列 (Create Eclipse EJB Project And Configure Queue)

  • To Configure HornetQ Destinations(Queues or Topics) with JBoss 6 AS, create an EJB Project in Eclipse IDE
    要使用JBoss 6 AS配置HornetQ目标(队列或主题),请在Eclipse IDE中创建一个EJB项目。
  • Provide Project name “HornetQConfigApp” and select Target runtime “JBoss 6.x Runtime”

    提供项目名称“ HornetQConfigApp”,然后选择目标运行时“ JBoss 6.x Runtime”

    Click on Finish Button. Now Project structure looks like

    单击完成按钮。 现在项目结构看起来像

    Create “hornetq-jms.xml” file at “ejbModule\METAINF” directory to add new Queue

    在“ ejbModule \ METAINF”目录下创建“ hornetq-jms.xml”文件以添加新队列

    hornetq-jms.xml – It is used to configure JMS Destinations (Queues and Topics) for HornetQ JMS Provider

    hornetq-jms.xml –用于为HornetQ JMS Provider配置JMS目标(队列和主题)

<configuration xmlns="urn:hornetq" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd"><queuename="JDQueue"><entryname="queue/JDQueue"/></queue>
</configuration>
  • Deploy this Queue configuration into JBoss 6.x AS
    将此队列配置部署到JBoss 6.x AS中
  • Right click on Server and select “Add and Remove” option

    右键单击服务器,然后选择“添加和删除”选项

    Select our application and click on “Add>” button then “Finish”

    选择我们的应用程序,然后单击“添加>”按钮,然后单击“完成”

    Now our required Queue “jms/JDQueue” is created in JBoss 6 AS – HornetQ Message Broker successfully.

    现在,我们已在JBoss 6 AS – HornetQ Message Broker中成功创建了所需的队列“ jms / JDQueue”。

    制定生产者和消费者计划 (Develop The Producer and Consumer Programs)

    • Create new Java Project to develop JMS Publisher and Consumer applications
      创建新的Java项目以开发JMS Publisher和Consumer应用程序
    • Create JBossJMSPublisher program

      创建JBossJMSPublisher程序

    import javax.jms.*;
    import javax.naming.*;
    public class JBossJMSPublisher {public static void main(String[] args) throws Exception{Context context = new InitialContext();ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("/ConnectionFactory");       Destination queue = (Destination)context.lookup("queue/JDQueue");Connection connection = connectionFactory.createConnection();Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);MessageProducer producer = session.createProducer(queue);TextMessage sntMessage =session.createTextMessage("JD Sample JMS Queue Message");producer.send(sntMessage);System.out.println("Message Sent successfully.");connection.close();}
    }

    Create JMS Consumer Program

    创建JMS消费者计划

    import javax.jms.*;
    import javax.naming.*;
    public class JBossJMSConsumer {public static void main(String[] args) throws Exception{Context context = new InitialContext();ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("/ConnectionFactory");        Destination queue = (Destination)context.lookup("queue/JDQueue");Connection connection = connectionFactory.createConnection();Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);MessageConsumer consumer = session.createConsumer(queue);connection.start();TextMessage rcvMessage = (TextMessage) consumer.receive();System.out.println("Received Msg = " + rcvMessage.getText());connection.close();}
    }
  • Define JBoss AS JNDI in jndi.properties at “src” folder
    在“ src”文件夹的jndi.properties中定义JBoss AS JNDI
  • jndi.properties

    jndi.properties

    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    java.naming.provider.url=jnp://localhost:1099
  • Add required jars to Project Build path
    将所需的jar添加到Project Build路径
  • Use “Add Library” button to add JBoss 6.x Library

    使用“添加库”按钮添加JBoss 6.x库

  • Final project looks like
    最终项目看起来像
  • 运行并观察结果 (Run and Observe The results)

    • Now test JMS application
      现在测试JMS应用程序
    • Run JMS Producer program to send messages to JBoss 6.x AS HornetQ Queue

      运行JMS Producer程序以将消息发送到JBoss 6.x AS HornetQ Queue

      Run JMS Consumer program and observe the message

      运行JMS Consumer程序并观察消息

    That’s it all about developing Simple JMS API 1.1 Producer and Consumer application with JBoss 6.0 Server. We will discuss JMS API 2.0 Producer and Consumer Example in my coming posts.

    这就是使用JBoss 6.0 Server开发Simple JMS API 1.1 Producer和Consumer应用程序的全部内容。 我们将在我的后续文章中讨论JMS API 2.0生产者和使用者示例。

    Please drop me a comment if you like my post or have any issues/suggestions.

    如果您喜欢我的帖子或有任何问题/建议,请给我评论。

    翻译自: https://www.journaldev.com/9906/jms1-1-with-eclipse-and-jboss6-example

    ejb 2.1 jboss

ejb 2.1 jboss_带有Eclipse IDE,EJB Project和JBoss 6.0 AS的JMS 1.1生产者和使用者示例相关推荐

  1. 具有Eclipse和嵌入式JBoss HornetQ Server的简单JMS 1.1生产者和使用者示例

    Before going to through this post, please read my previous post at "JMS API 1.1 Producer and Co ...

  2. Eclipse IDE for Java EE Developers 与Eclipse Classic 区别

    eclipse下载官网:eclipse下载 版本: 1.eclipse classic 是eclipse的标准版:标准版; 2.eclipse ide for java developer : 标准版 ...

  3. jigsaw kaggle_使用Project Jigsaw的JDK 9 Early Access上的Eclipse IDE

    jigsaw kaggle 几周前,我写了关于在Java 9上运行Eclipse Neon的文章 (尽管,我在帖子标题中错误地且令人尴尬地留下了"火星"). 值得注意的是,我列出的 ...

  4. 使用Project Jigsaw的JDK 9 Early Access上的Eclipse IDE

    几周前,我写了关于在Java 9上运行Eclipse Neon的文章 (尽管,我在帖子标题中错误地和令人尴尬地留下了"火星"). 值得注意的是,我列出的步骤也适用于带有Projec ...

  5. 如何使用Python入侵Eclipse IDE

    Eclipse Advanced Scripting Environment( EASE )项目是一组新的但功能强大的插件,使您能够快速破解Eclipse IDE. Eclipse是一个功能强大的框架 ...

  6. 定制Eclipse IDE之插件篇(一)

    本文转自 海角在眼前 博客园博客,原文链接: http://www.cnblogs.com/lovesong/p/4694688.html  ,如需转载请自行联系原作者 上文回顾:定制Eclipse ...

  7. 定制Eclipse IDE之界面篇

    为什么要定制IDE? 在工作时候,当公司有了自己的框架,给自己开放人员用,甚至是可以卖的时候,我们可以做成一个产品,而这个产品将包括框架本身.文档.工具.教程等等.工具之中最重要的莫过于开发工具(ID ...

  8. JBoss Eclipse IDE

    2019独角兽企业重金招聘Python工程师标准>>> JBoss Eclipse IDE Tools 1.4.1 Stable,在Eclipse V3.1的里程碑版本6(M6)极其 ...

  9. Eclipse IDE for Enterprise Java Developers和JDK8与apache-tomcat-8下载地址

    jdk1.8.0_201下载地址: 官网下载页:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133 ...

最新文章

  1. 远心镜头技术及其选型介绍
  2. 错误:AttributeError: module 'enum' has no attribute 'IntFlag'
  3. 关于知识整理、积累与记忆
  4. Activity生命周期的补充
  5. LeetCode 1059. 从始点到终点的所有路径(回溯)
  6. 服务器iis配置 所需文件,iis服务器配置手册.pdf
  7. vs2008下的javascript语法检查工具——JSLint.VS
  8. D7-Nginx-SSL
  9. 【CF1342D】Multiple Testcases(贪心+优先队列)
  10. 网刻工具大全:四款软件优缺评析(转)
  11. 子网划分的计算与可用主机数
  12. U盘安装win7 启动一键u盘安装Ghost Win7系统教程
  13. 如何快速有效的复习教师资格证?
  14. 单片机C语言GRB888和RGB565的互相转换
  15. iwatch可以用计算机吗,千万不要买AppleWatch的5个原因!
  16. 第二课:创建三层神经网络解决非线性问题
  17. 用vb.net写一个简易的RSS阅读器
  18. 用于图像识别的神经网络,以及5大应用场景
  19. php 获取微博cookie,如何获取微博 Cookie
  20. 【深度学习之美】BP算法双向传,链式求导最缠绵(入门系列之八)

热门文章

  1. JAVA 1.5 并发之 Executor框架 (内容为转载)
  2. 不会框架不要紧,我带你自定义框架
  3. Nessus虚拟机的几个问题解决办法
  4. ABP应用层——参数有效性验证
  5. 数据结构实验病毒感染检测问题(C++)
  6. cf519D . A and B and Interesting Substrings 数据结构map
  7. Uvalive - 3026 Period (kmp求字符串的最小循环节+最大重复次数)
  8. 查看windows系统热键占用情况
  9. HDU3507 Print Article(斜率优化dp)
  10. 3D MRI brain tumor segmentation using autoencoder regularization