Spring Integrated JMS Usage
The JMS full name Java Message Service, which is used to send messages.
1. Advantages1. Relative RPC achieves the decoupling effect: Decoupling from the Service Interface name (changing the interface name in RPC, the client needs to make modifications), decoupling from the service location (RPC needs to configure the service's network location to use the service),
JMS-based Active MQ message storage, jmsmqI. Message Storage Methods
ActiveMQ supports persistent messages and non-persistent messages in JMS specifications.
Persistent messages are usually used to ensure that messages are consumed by consumers regardless of whether the consumers are online or not. After the message is confirmed to be consumed, it will be deleted from the storage.
Non-persistent messages
Use Apache Flume to read the JMS Message Queuing message and write the message to the Hdfs,flume agent configuration as follows:Flume-agent.conf#name the components in this agentagenthdfs.sources = Jms_sourceAgenthdfs.sinks = Hdfs_sinkAgenthdfs.channels = Mem_channel# Describe/configure The sourceAgentHdfs.sources.jms_source.type = JMS# Bind to all interfacesAgentHdfs.sources.jms_source.initialContextFactor
1: ActiveMQ Zookeeper-based master-slave (LevelDB master/slave) construction and Spring-boot use (http://www.cnblogs.com/yshyee/p/7277801. HTML), the following code is used to send the JMS message:@Service Public class Producer { @Autowired private jmsmessagingtemplate jmstemplate; Public void Final String message) { jmstemplate.convertandsend (destination, message);} }After using JMeter for stress testing, it was found that
Select Activemq.
To establish a simple Maven project, the Pom.xml is as follows:
To create a test class:
Package com.gof.jms.test;
Import javax.jms.Connection;
Import Javax.jms.ConnectionFactory;
Import Javax.jms.DeliveryMode;
Import javax.jms.Destination;
Import Javax.jms.Message;
Import Javax.jms.MessageConsumer;
Import Javax.jms.MessageProducer;
Import javax.jms.Session;
Import Javax.jms.TextMessage;
Import Org.apache.activemq.ActiveMQConnectionFactory;
public class Simplemessagesend
(subscriber). The client sends the message to the topic. Multiple publishers send messages to topic, which the system passes to multiple subscribers. Each message can have multiple consumers There is a time dependency between the Publisher and the Subscriber. Subscribers to a topic (TOPIC) must create a subscription before they can consume the publisher's message and, in order to consume the message, the Subscriber must remain in a running state.Of course, to mitigate this strict time depende
JPA
Java persistence API.
JPA uses JDK 5.0 annotations or XML to describe the ing relationship between objects and Relational Tables, and persistently stores object objects in the database at runtime.
Baidu Encyclopedia: http://baike.baidu.com/view/1036852.htm
JTA
Java transaction API, translated as Java transaction API.
JTA allows applications to execute Distributed Transaction Processing-accessing and updating data on two or more network computer resources. The JTA support of the JDBC driver
model, there are the following concepts:
Theme (Topic),
Publisher (publisher),
Subscribers (subscriber).
The client sends the message to the topic. Multiple publishers send messages to topic, which the system passes to multiple subscribers.? Each message can have multiple consumers? There is a time dependency between the Publisher and the Subscriber . Subscribers to a topic (TOPIC) must create a subscription before they can consume the publisher's message and, in order to
for class two modes in Springboot. But JMS-specific scenarios are between different applications, where producers and consumers are often in different applications. In addition, the message in the above example we send only strings, in fact, can also send the object type of message, can even use Messagecreator custom message conversion, instead of using the Convertandsend method default conversion.Sending messages between multiple applications1. Firs
SPRINGMVC + Mybatis + springsecurity (Permission control to method button) + Rest (service) + Webservice (service) + Quartz (timed dispatch) + Lucene (search engine) + HTML5 Bootstrap + Maven Project to build an absolute open source platformProject Mave Construction, simulation of large-scale Internet architecture, to achieve high concurrency, large data processing, the entire project using customized service ideas, to provide an atomic, modular scheme, the function module is split, can be commo
Today, my colleague asked me how to handle the JMS messages of receive and visible. A little bit ignorant, before the state of the message has never been concerned. In the Weblogic81, we can't see the message in destination, we can only see how many messages there are in the current destination, how many pending are there. And in 92, when we monitor the destination, we can see the specific message, and the message follows a state string. The title of
For many friends, want to be familiar with JMS related development knowledge, online example write is also more chaotic, special manual compiled an example and server configuration, I hope you like, support my
1 JBoss Configuration Queue Message Queue
Open the JBoss installation directory and locate the file Jbossmq-destinations-service.xml file under SERVER/DEFAULT/DEPLOY/JMS
Add the configuration code as
Session session = Connection.createsession (PARAMA,PARAMB);
Parama is set transaction, PARAMB is set acknowledgment mode
Parama values are:
1. True: Support transactions
When true: The value of PARAMB is ignored, acknowledgment mode is set to session_transacted by the JMS server.
2. False: Transaction not supported
When false: The value of Paramb can be one of Session.auto_acknowledge, Session.client_acknowledge, Dups_ok_acknowledge.
Paramb val
The JMS API defines five types of message bodies:
--------------------------------------------------------------------------------------------------------------- ----Stream-The message body of the Streammessage object contains the Java programming language primitive value stream ("Java basic type"). Populate and read sequentially.Map-The message body of the Mapmessage object contains a set of name-value pairs, where the name is a String object and th
Ack_mode Confirm Mode
--------------------------------------------------------------------------------------------------------------- -----The confirmation mode is used to indicate how the session confirms receipt of the message, which needs to be specified when using the connection CreateSession method, and the following four options are included in the JMS session interface· Auto_acknowledge = 1 Automatic ConfirmationThe session automatically confi
listener =New Pubsublistener ("Client_one",new Jedis ( "127.0.0.1")); Subclient subclient = new subclient ( "127.0.0.1", listener); Thread T1 = new Thread (new Runnable () { @Override public void run () {//at the API level, this is a polling operation and will not return unsubscribe until Subclient.sub is called ( Channel); } }); T1.setdaemon (true); T1.start (); int i = 0; while (i 2) {Pubclient.publish (channel, " "Message" +i); i++; Thread.Sleep (1000);}}
1
2
3
This article is a simple integration method for spring and activemq. It is only used for reference learning and focuses on understanding concepts.
1: JMS is a set of standard APIs developed by Sun to access message-oriented middleware (MOM). The mom component used in this article is activemq. You can go to [url] routing,
It is very simple to use, extract and directly run the activemq. BAT file under the D:/activemq-4.1.1/bin directory, you can start t
In the development of message-oriented middleware, it is often necessary to generate a unique message identifier. You can add a corresponding prefix to the server deployed in the project, and then the timestamp is too long based on the system timestamp, it can be converted into a 36-digit string to form the unique identifier of the message:
import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;public class MsgIDUtil {private static fi
Jar hell III: the issue and solution of log4j 1.2.15 in m2eclipse
The version 1.3 of log4j is still in the Alibaba Cloud version. Version 1.2 is up to version 1.2.15, but maven2 has an issue in eclipse.
After installing Maven clean, the maven package will build failure, with the following warning information:[Warning] invalid Pom for javax. JMS: jar: 1.1, transitive dependencies (if any) will not be available, enable debug logging for more details[W
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.