Active MQ C++ implements communication record

Active MQ C++ realizes communication

 

background knowledge:

ActiveMQ is an easy-to-use messaging middleware.

message middleware

Let's briefly introduce the message middleware, just have a basic understanding of it, the message middleware (MOM: Message Orient middleware).

Message middleware has many uses and advantages: 
1. Transfer data from one application to another, or from one software module to another; 
2. Responsible for establishing network communication channels for reliable data send. 3. To ensure that the data
is not retransmitted and not lost 

SQM

First of all, I will briefly introduce MQ. The English name of MQ is MessageQueue. The Chinese name is also the message queue that everyone uses. Why do you use it? To put it bluntly, it is a container for receiving and forwarding messages, which can be used for message push.

Let's enter our topic today and introduce ActiveMQ to you:

ActiveMQ

Brief overview of ActiveMQ

Apache ActiveMQ ™ is the most popular and powerful open source messaging and Integration Patterns server.
Apache ActiveMQ is fast, supports many Cross Language Clients and Protocols, comes with easy to use Enterprise Integration Patterns and many advanced features while fully supporting JMS 1.1 and J2EE 1.4. 

ActiveMQ is produced by Apache, one of the most popular and powerful open source message bus. ActiveMQ is a JMS Provider implementation that fully supports JMS1.1 and J2EE 1.4 specifications. It is very fast, supports clients and protocols in multiple languages, and can be easily embedded into enterprise application environments with many advanced features.

When to use ActiveMQ?

  1. Integration between multiple projects 
    (1) Cross-platform 
    (2) Multilingual 
    (3) Multi-project
  2. Reduce the coupling degree of modules between systems, decoupling 
    (1) Software scalability
  3. System front and rear isolation 
    (1) Front and rear isolation, shielding high security area
  4. Write clients in multiple languages ​​and protocols. Languages: Java, C, C++, C#, Ruby, Perl, Python, PHP. Application Protocol: OpenWire, Stomp REST, WS Notification, XMPP, AMQP
  5. Full support for JMS1.1 and J2EE 1.4 specifications (persistence, XA messages, transactions)
  6. For the support of Spring, ActiveMQ can be easily embedded into the system using Spring, and also supports the features of Spring 2.0
  7. Passed the tests of common J2EE servers (such as Geronimo, JBoss 4, GlassFish, WebLogic), and through the configuration of JCA 1.5 resource adaptors, ActiveMQ can be automatically deployed to any compatible J2EE 1.4 commercial server.
  8. Supports multiple transport protocols: in-VM, TCP, SSL, NIO, UDP, JGroups, JXTA
  9. Supports high-speed message persistence via JDBC and journal
  10. High-performance clustering, client-server, peer-to-peer, guaranteed by design
  11. Ajax support
  12. Support integration with Axis
  13. It is easy to call the embedded JMS provider for testing

ActiveMQ feature list

The default TCP connection port used by ActiveMQ is 61616

Application Scenario:

Message queues are widely used in large e-commerce websites, such as JD.com, Taobao, Qunar, etc. The main function of queues is to eliminate high concurrent access peaks and speed up website response. In the case of not using the message queue, the user's request data is directly written to the database. In the case of high concurrency, it will cause huge pressure on the database and also increase the system response delay. After using the queue, the user's request is sent to the queue and returned immediately (of course, the user cannot be directly notified that the order has been submitted successfully, JD.com prompts: "You have submitted the order, please wait for the system to confirm"), and then the message queue consumer The process gets data from the message queue and writes it to the database asynchronously. Since the service processing speed of the message queue is much faster than that of the database, the response delay of the user can be effectively improved.


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Steps

1. Download version

ActiveMQ-cpp-2.2.6

apr-1.6.2

apr-iconv-1.2.1

apr-util-1.6.0

2. The path is D:\GCN\MQClient\Activemq-cpp\tags

Remove the version number of the dependent library

apr-util  ,apr-1.6.2 ,apr-iconv

 

3. Open D:\GCN\MQClient\Activemq-cpp\tags\activemq-cpp-2.2.6\vs2005-build

Compile dependencies as apr-util -> apr-iconv -> apr

  1. Precautions

When compiling to libaprutil, Debug depends on expat.lib, and release depends on xml.lib .

 

 

Debug:

E:\GCN\20170831SVN_MAIN\trunk\Product\MQClient\apr-util\xml\expat\lib

 

Release:

 

  1. Compile vs2005-activemq

    Set up dependencies, attach library header files, and attach library lib paths.

  1. Compile vs2005-activemq-example

 

 

 

 

config file:

Vs2005-activemq-cpp.exe

activemq.cfg

 

##### Global configuration parameters######

host_id=35

node_id=3236

cmdline = 1

Consumer = 1 (Producer and Consumer switch)

 

#Configure restart

#reset_time = 0,20:00:00

reset_time = 06:15:00

sync_time = 0

sync_interval = 60

accept_sync_time = 0

 

#MQConfiguration

mq_url = tcp: //10.1.6.2: 61616

mq_user      = jlt_mq

mq_pwd = jlt_mq123

mq_topic     = jlt.srv.quote.engine.pubQuote.topic.queueName

#mq_topic    = QUOTATION.WJF.TEST

#read shared queue

mem_que_name = QUEUE_MQ_SERVER

other_inst_multi = 1000

forex_inst_multi = 10000

 

#Write to the shared queue

XQUE_NUM = 2

XQUE1.XQUE_NAME = MQ_QUOTATION3

XQUE1.WAIT_PERMIT = 10000

XQUE1.BUFFER_PERMIT = 10000

XQUE1.MAIN = 1

XQUE1.MODE = 1

 

XQUE2.XQUE_NAME = MQ_QUOTATION4

XQUE2.XQUE_TIMEOUT = 1000

XQUE2.WAIT_PERMIT = 10000

XQUE2.BUFFER_PERMIT = 10000

XQUE2.MAIN = 1

XQUE2.MODE = 1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325022670&siteId=291194637