项目作者: cheeray

项目描述 :
Bridge JMS (MQ) to Restful services.
高级语言: Java
项目地址: git://github.com/cheeray/jms-rest.git
创建时间: 2017-03-21T02:16:21Z
项目社区:https://github.com/cheeray/jms-rest

开源协议:

下载


JMS Restful Bridge

Introduction

Annotation based MQ adapter, alternative of wmq resouce adaptor.

Feature

  1. Configurable backout queues and threads.
  2. Full of start/Stop control via CDI event or JMX.
  3. Standalone JMS to Restful transparent bridge.

Getting Start

  1. Run “etc/install_mq_dependencies.bat” to install mq dependencies to local repository;
  2. Run “mvn package” to build;

Integrate in JSE and JEE.

Run “etc/publish_jms_util.bat” to publish project to local repository;

Include maven depenceny:

  1. <dependency>
  2. <groupId>com.cheeray</groupId>
  3. <artifactId>jms-rest</artifactId>
  4. <version>1.0-SNAPSHOT</version>
  5. </dependency>

Configure system properties:

  1. JMS_UTIL_WAIT_INTERVAL: Timeout of reading a message, default is 1000, set to 0 will be waiting unlimitedly.
  2. JMS_UTIL_RETRY_INTERVAL: Interval to retry connection, default is 10000.
  3. JMS_UTIL_SLEEP_INTERVAL: Interval to wait for new message, default is 100ms.

Annotation (consumer):

  1. /**Annotate the class with @MAware and the method that consuming a string message with @MConsumer, for example:*/
  2. @MAware
  3. public class Consumer {
  4. ...
  5. @MConsumer({ @MQueue(channel = "CLIENT.MQ.CHANNEL", host = "MQ_HOST",
  6. manager = "MQ_MANAGER", port = 3434, queue = "MQ.QUEUE.IN") })
  7. public void onInbound(String msg) throws InterruptedException {
  8. // TODO: process the string message.
  9. }
  10. ...
  11. }

Annotation (producer):

  1. /**Annotate the class with @MAware and the method that consuming a string message with @MProducer, for example:*/
  2. @MAware
  3. public class Producer {
  4. ...
  5. @MProducer(value = { @MQueue(channel = "CLIENT.MQ.CHANNEL",
  6. host = "MQ_HOST", manager = "MQ_MANAGER", port = 3434,
  7. queue = "MQ.QUEUE.IN") }, backouts = { @MQueue(
  8. channel = "CLIENT.MQ.CHANNEL.BO", host = "MQ_HOST_BO",
  9. manager = "MQ_MANAGER_BO", port = 3434, queue = "MQ.QUEUE.IN.BO") })
  10. public String send(...) throws InterruptedException {
  11. // TODO: process the string message.
  12. }
  13. ...
  14. }

Known issues:

Before CDI 1.2, producer is not auto intercepted, see http://docs.jboss.org/weld/reference/latest/en-US/html_single/#_enabling_interceptors.

Alternatively, a DispatchEvent can be fired inside the producing method to send the message directly.

Run JMS-Restful bridge:

Configuration

  • Copy “conf/jms-rest.yaml.example” to “conf/jms-rest.yaml” and modify below settings:
Inbound and Outbound MQ setting:
  1. Setting | Description
  2. ----------|----------
  3. host | MQ host
  4. port | MQ port
  5. channel | MQ channel
  6. manager | MQ manager
  7. queues | Queue names
  8. threads | Number of threads to run
Inbound and Outbound RESTful setting:
  1. Setting | Description
  2. ----------|-------------
  3. scheme |HTTP scheme
  4. server |RESTful server
  5. port |Listen/Pubish port
  6. context |RESTful service context
  • Run “etc/start-jms-rest.bat” to start as standalone mode.
  • Or copy “init.d/jms-rest.sh” to “/etc/init.d/“ and run as Linux service.

Linux service

  1. Create a nologin user (default “jms-rest”) and set to “JMS_REST_USER” in “JMS_REST_CONF”, default configuration file is “/etc/default/jms-rest.conf”.
  2. Set “JMS_REST_HOME” (default “/opt/jms-rest”).
  3. Copy “bin”, “conf” and “target/jms-rest-bridge.jar” to “JMS_REST_HOME”.
  4. Copy “init.d/jms-rest.sh” to “/etc/init.d/“ and “chmod” as runnable Linux service.
  5. Start “service jms-rest start”.

Log

Set “JMS_REST_LOG_DIR” to the directory for logs. Default is “/var/log/jms-rest” and “bridge.log” is the log file.

License

Apache License Version 2.0