Build Messaging Between Ruby/Rails Applications with ActiveMQ
https://dev.to/kirillshevch/build-messaging-between-ruby-rails-applications-with-activemq-4finposted @ 2019-07-12 17:12 paulwong 閱讀(344) | 評論 (0) | 編輯 收藏
posted @ 2019-07-12 17:12 paulwong 閱讀(344) | 評論 (0) | 編輯 收藏
posted @ 2019-07-11 11:45 paulwong 閱讀(325) | 評論 (0) | 編輯 收藏
posted @ 2019-07-02 11:13 paulwong 閱讀(1083) | 評論 (0) | 編輯 收藏
posted @ 2019-06-28 10:24 paulwong 閱讀(348) | 評論 (0) | 編輯 收藏
Request-Response is a message-exchange-pattern. In some cases, a message producer may want the consumers to reply to a message. The JMSReplyTo header indicates which destination, if any, a JMS consumer should reply to. The JMSReplyTo header is set explicitly by the JMS client; its contents will be a javax.jms.Destination object (either Topic or Queue).
In some cases, the JMS client will want the message consumers to reply to a temporary topic or queue set up by the JMS client. When a JMS message consumer receives a message that includes a JMSReplyTo destination, it can reply using that destination. A JMS consumer is not required to send a reply, but in some JMS applications, clients are programmed to do so.
For simplicity, this pattern is typically implemented in a purely synchronous fashion, as in web service calls over HTTP, which holds a connection open and waits until the response is delivered or the timeout period expires. However, request–response may also be implemented asynchronously, with a response being returned at some unknown later time.
For more information, check here.
Now, let’s jump into the code. In Spring, there are 2 ways to implement this (at least I know of).
For demo purpose, I used ActiveMQ. However, you can implement this in other messaging systems like IBM MQ, Rabbit MQ, Tibco EMS, etc. In this demo, I send an ObjectMessage of type Order and reply with a Shipment object.
First, we include the required dependencies. Replace the activemq
dependency with your messaging system’s jars if not using ActiveMQ
Using the default spring.activemq. properties to configure the application with the ActiveMQ. However, you can do this inside a @Configuration class as well.
Now spring will do it’s magic and inject all the required Beans as usual :) However, in our code, we need to EnableJms
First, we will configure the Producer
Next, we can see the Receiver
First, we include the required dependencies in addition to the above dependencies
Using the default spring.activemq. properties to configure the application with the ActiveMQ. However, you can do this inside a @Configuration class as well.
Next we create the required Beans for the Spring Integration.
Next, we will configure the MessagingGateway
We then Autowire this gateway in our Component class when we want to send and receive the message. A sample is shown below.
For those, who just want to clone the code, head out to aniruthmp/jms
posted @ 2019-06-27 09:20 paulwong 閱讀(474) | 評論 (0) | 編輯 收藏
posted @ 2019-06-26 14:13 paulwong 閱讀(345) | 評論 (0) | 編輯 收藏
posted @ 2019-06-24 17:42 paulwong 閱讀(433) | 評論 (0) | 編輯 收藏
posted @ 2019-06-20 15:12 paulwong 閱讀(338) | 評論 (0) | 編輯 收藏
[root@kvm5 ~]# yum install -y nfs-utils
[root@kvm5 ~]# mkdir /public /protected
[root@kvm5 ~]# semanage fcontext -a -t public_content_t "/public(/.*)?" [root@kvm5 ~]# semanage fcontext -a -t public_content_t "/protected(/.*)?" [root@kvm5 ~]# restorecon -Rv /public /protected
[root@kvm5 ~]# wget http://deyu.wang/kvm5.keytab -O /etc/krb5.keytab
[root@kvm5 ~]# date Sun Jan 7 14:50:04 CST 2018 [root@kvm5 ~]# chronyc -a makestep 200 OK 200 OK [root@kvm5 ~]# date Mon Nov 20 15:53:22 CST 2017
[root@kvm5 ~]# mkdir -p /protected/restricted
[root@kvm5 ~]# chown deyu3 /protected/restricted
[root@kvm5 ~]# echo '/protected 192.168.122.0/24(rw,sync,sec=krb5p)' > /etc/exports [root@kvm5 ~]# echo '/public 192.168.122.0/24(ro,sync)' >> /etc/exports [root@kvm5 ~]# vim /etc/exports [root@kvm5 ~]# cat /etc/exports /protected 192.168.122.0/24(rw,sync,sec=krb5p) /public 192.168.122.0/24(ro,sync)
[root@kvm5 ~]# man 5 nfs
[root@kvm5 ~]# vim /etc/sysconfig/nfs sed -i 's/^\(RPCNFSDARGS=\).*$/\1\"-V 4.2\"/' /etc/sysconfig/nfs
[root@kvm5 ~]# grep ^RPCNFSDARGS /etc/sysconfig/nfs RPCNFSDARGS="-V 4.2"
[root@kvm5 ~]# systemctl enable nfs-server.service nfs-secure-server.service
[root@kvm5 ~]# systemctl start nfs-server.service nfs-secure-server.service
[root@kvm5 ~]# cat /proc/fs/nfsd/versions -2 +3 +4 +4.1 +4.2
[root@kvm5 ~]# systemctl status nfs-secure-server.service nfs-server.service
nfs-secure-server.service - Secure NFS Server
Loaded: loaded (/usr/lib/systemd/system/nfs-secure-server.service; enabled)
Active: active (running) since Mon 2015-09-21 20:04:10 CST; 8s ago
Process: 3075 ExecStart=/usr/sbin/rpc.svcgssd $RPCSVCGSSDARGS (code=exited, status=0/SUCCESS)
Main PID: 3077 (rpc.svcgssd)
CGroup: /system.slice/nfs-secure-server.service
└─3077 /usr/sbin/rpc.svcgssd
Sep 21 20:04:10 kvm5.deyu.wang systemd[1]: Starting Secure NFS Server
Sep 21 20:04:10 kvm5.deyu.wang systemd[1]: Started Secure NFS Server.
nfs-server.service - NFS Server
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled)
Active: active (exited) since Mon 2015-09-21 20:04:10 CST; 8s ago
Process: 3078 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
Process: 3076 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
Process: 3087 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT (code=exited, status=0/SUCCESS)
Process: 3084 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Process: 3083 ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/SUCCESS)
Main PID: 3087 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
Sep 21 20:04:10 kvm5.deyu.wang systemd[1]: Starting NFS Server
Sep 21 20:04:10 kvm5.deyu.wang systemd[1]: Started NFS Server.
nfs-utils-1.3.0-8.el7.x86_64
啟動 nfs-secure-server 出現(xiàn)錯誤訊息,請執(zhí)行 yum downgrade nfs-utils 換成 nfs-utils-1.3.0-0.el7.x86_64
套件。[root@kvm5 ~]# rpm -qa | grep nfs-utils
nfs-utils-1.3.0-8.el7.x86_64
[root@kvm5 ~]# yum downgrade nfs-utils -y
[root@kvm5 ~]# rpm -qa | grep nfs-utils
nfs-utils-1.3.0-0.el7.x86_64
[root@kvm5 ~]# systemctl restart nfs-server.service nfs-secure-server.service
[root@kvm5 ~]# exportfs -arv
exporting 192.168.122.0/24:/public
exporting 192.168.122.0/24:/protected
posted @ 2019-06-18 09:08 paulwong 閱讀(396) | 評論 (0) | 編輯 收藏
posted @ 2019-06-14 10:24 paulwong 閱讀(363) | 評論 (0) | 編輯 收藏