A summary of the use of analytic activemq _c language

Source: Internet
Author: User
Tags ack failover
This article is only for the ACTIVEMQ common problems to introduce. Basic applications such as downloading, compiling, deploying, and using are not covered in this article.
1, ACTIVEMQ Support message filtering settings rules and usage
Selector supports the following ways:
(1) String literals: "color = ' Blue '"
(2) Byte strings: "Mybytes <>" 0x0afc23 ""
(3) Numeric values: "Noltemsinstock > 20"
(4) Boolean literals TRUE or FALSE: "Acctdetails=true"
(5) Composite Expressions: "Type= ' Car" and (color = ' Blue ' OR color = ' green ') and weight> 2500 "
How to use:
(1) Create a Producer add filter properties before the Send function:
message->setstringproperty ("Color", Pcolor);
producer->send (Message );
(2) When creating consumer Createconsumer, make the following settings:
std::string messagefilter= "color = ' Blue '"
M_pconsumer = M_psession->createconsumer (m_pdestination, M_messagefilter);
M_pconsumer->setmessagelistener (this);
2. Error: Channel is inactive for too long (the client will report this error if the server message is not sent for a long time)
Workaround: Add in the URI that establishes the connection: wireformat.maxinactivityduration=0
3, the use of failover mode of connection leading to the death card
Workaround: Do not use failover connection
4, Activemq send mode
(1) Activemq asynchronous Send, just add the parameter transport.useasyncsend=true, specifically as follows:
brokeruri = "tcp://127.0.0.1:61616?" transport.useasyncsend=true"
(2) Activemq synchronous Send, just add the parameter transport.useasyncsend=false, specifically as follows:
brokeruri = "tcp://127.0.0.1:61616?" transport.useasyncsend=false"
In fact , ACTIVEMQ is sent synchronously by default, so it can be abbreviated when sent synchronously:
Brokeruri = "tcp://127.0.0.1:61616 "
5. Error: The session is closed (the client will report this error when the network is abnormal)
Workaround: Add in the URI that establishes the connection: maxreconnectdelay=10000
Maxreconnectdelay Maximum Heavy interconnect interval
6, ACTIVEMQ is responsible for the balance
Load balancing for broker and primary provisioning based on shared file systems, where client-side producers and consumers ' URIs use
Failover: (tcp://192.168.1.117:61616,tcp://192.168.1.118:61616,tcp://broker3:61616)
6, Activemq ACK settings
depending on your needs, you can set the ACK to Session::client_acknowledge or Session::auto_acknowledge defaults to session : : Auto_acknowledge such as:
If(clientack)
{
Session = Connection->createsession (Session::client_acknowledge);
}
Else
{
Session = Connection->createsession (Session::auto_acknowledge);
}
7, ACTIVEMQ topic settings
Depending on your needs, you can set topic to topic or queue defaults to queue such as:
If(usetopic)
{
Destination = session->createtopic (Desturi );
}
Else
{
Destination = Session->createqueue (Desturi );
}
8, Activemq DeliveryMode settings (producer time set)
Depending on your needs, you can set DeliveryMode to deliverymode::non_persistent or deliverymode::Persistent defaults to deliverymode::non_persistent such as:
if(usepersistent)
{
Producer->setdeliverymode ( deliverymode::P ersistent);
}
Else
{
Producer->setdeliverymode ( deliverymode::non_persistent);
}
 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.