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 "
(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
(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)
depending on your needs, you can set the ACK to Session::client_acknowledge or Session::auto_acknowledge defaults to session : : Auto_acknowledge such as:
Session = Connection->createsession (Session::client_acknowledge);
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:
Destination = session->createtopic (Desturi );
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);
Producer->setdeliverymode ( deliverymode::non_persistent);