真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

activemq死信隊(duì)列怎么配置

本篇內(nèi)容介紹了“activemq死信隊(duì)列怎么配置”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

十多年建站經(jīng)驗(yàn), 成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè)客戶的見證與正確選擇。創(chuàng)新互聯(lián)提供完善的營銷型網(wǎng)頁建站明細(xì)報(bào)價(jià)表。后期開發(fā)更加便捷高效,我們致力于追求更美、更快、更規(guī)范。

監(jiān)聽新思路

1.不必去破壞生產(chǎn)者消費(fèi)者的關(guān)系,去創(chuàng)建死信隊(duì)列的對應(yīng)消費(fèi)者,如果不同隊(duì)列去創(chuàng)建對應(yīng)的死信隊(duì)列監(jiān)聽,沒什么意義,復(fù)用剛開始的思路進(jìn)行更改。mq配置更改指定監(jiān)聽死信隊(duì)列,死信隊(duì)列的名稱是可以配置指定的

@Bean    public ActiveMQConnectionFactory connectionFactory() throws JMSException {        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerurl);        factory.setTrustAllPackages(true);//信任所有包下的序列化對象,解決無法發(fā)送對象消息        javax.jms.Connection connection = factory.createConnection();        connection.start();        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);        Queue queue = session.createQueue("ActiveMQ.DLQ");        MessageConsumer messageConsumer = session.createConsumer(queue);        messageConsumer.setMessageListener(new QueueListener());        factory.setUserName(userName);        factory.setPassword(password);        return factory;    }

新建監(jiān)聽類

/** * @author zhaokkstart * @create 2020-09-11 11:18 */public class QueueListener implements MessageListener {    @Override    public void onMessage(Message message) {        System.out.println("****消費(fèi)者的消息:"+message);    }}

看下能從message獲取到什么東西

public interface Message {
   static final int DEFAULT_DELIVERY_MODE = DeliveryMode.PERSISTENT;
   static final int DEFAULT_PRIORITY = 4;
   static final long DEFAULT_TIME_TO_LIVE = 0;
   String getJMSMessageID() throws JMSException;
   void setJMSMessageID(String id) throws JMSException;
   long getJMSTimestamp() throws JMSException;
   void setJMSTimestamp(long timestamp) throws JMSException;
   byte[] getJMSCorrelationIDAsBytes() throws JMSException;
   void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException;
   void setJMSCorrelationID(String correlationID) throws JMSException;
   String getJMSCorrelationID() throws JMSException;
   Destination getJMSReplyTo() throws JMSException;
   void setJMSReplyTo(Destination replyTo) throws JMSException;
   Destination getJMSDestination() throws JMSException;
   void setJMSDestination(Destination destination) throws JMSException;
   int getJMSDeliveryMode() throws JMSException;
   void setJMSDeliveryMode(int deliveryMode) throws JMSException;
   boolean getJMSRedelivered() throws JMSException;
   void setJMSRedelivered(boolean redelivered) throws JMSException;
   String getJMSType() throws JMSException;
   void setJMSType(String type) throws JMSException;
   long getJMSExpiration() throws JMSException;
   void setJMSExpiration(long expiration) throws JMSException;
   int getJMSPriority() throws JMSException;
   void setJMSPriority(int priority) throws JMSException;
   void clearProperties() throws JMSException;
   boolean propertyExists(String name) throws JMSException;
   boolean getBooleanProperty(String name) throws JMSException;
   byte getByteProperty(String name) throws JMSException;
   short getShortProperty(String name) throws JMSException;
   int getIntProperty(String name) throws JMSException;
   long getLongProperty(String name) throws JMSException;
   float getFloatProperty(String name) throws JMSException;
   double getDoubleProperty(String name) throws JMSException;
   String getStringProperty(String name) throws JMSException;
   Object getObjectProperty(String name) throws JMSException;
   Enumeration getPropertyNames() throws JMSException;
   void setBooleanProperty(String name, boolean value) throws JMSException;
   void setByteProperty(String name, byte value) throws JMSException;
   void setShortProperty(String name, short value) throws JMSException;
   void setIntProperty(String name, int value) throws JMSException;
   void setLongProperty(String name, long value) throws JMSException;
   void setFloatProperty(String name, float value) throws JMSException;
   void setDoubleProperty(String name, double value) throws JMSException;
   void setStringProperty(String name, String value) throws JMSException;
   void setObjectProperty(String name, Object value) throws JMSException;
   void acknowledge() throws JMSException;
   void clearBody() throws JMSException;}

還是對象里的那點(diǎn)東西,到有個(gè)新思路

  commandId = 5,    responseRequired = true,    messageId = ID: kk - 59648 - 1599635155556 - 1: 239: 1: 1: 1,     originalDestination = null, originalTransactionId = null,     producerId = ID: kk - 59648 - 1599635155556 - 1: 239: 1: 1,     destination = queue: //add_xxxxxx,     transactionId = null, expiration = 0, timestamp = 1599636301936, arrival = 0,     brokerInTime = 1599636301937, brokerOutTime = 1599636302110,     correlationId = null, replyTo = null, persistent = true, type = null,     priority = 4, groupID = null, groupSequence = 0,    targetConsumerId = null, compressed = false, userID = null,     content = org.apache.activemq.util.ByteSequence@54eae153,     marshalledProperties = org.apache.activemq.util.ByteSequence@1318dd4d,    dataStructure = null, redeliveryCounter = 0, size = 0, properties = {timestamp=1599636300958},    readOnlyProperties = true, readOnlyBody = true, droppable = false,    jmsXGroupFirstForConsumer = false}

不必去指定type維護(hù)隊(duì)列的信息關(guān)系,獲取

destination = queue: //add_xxxxxx,

即獲取originalDestination屬性,判斷此消息的入隊(duì)隊(duì)列是哪個(gè),然后獲取該隊(duì)列的消費(fèi)者入隊(duì)消息進(jìn)行轉(zhuǎn)換

這個(gè)方法是肯定能監(jiān)聽到死信隊(duì)列的,親測有效。

activemq死信隊(duì)列怎么配置

activemq死信隊(duì)列怎么配置

(1) 死信隊(duì)列的配置(一般采用默認(rèn))

1. sharedDeadLetterStrategy

不管是queue還是topic,失敗的消息都放到這個(gè)隊(duì)列中。下面修改activemq.xml的配置,可以達(dá)到修改隊(duì)列的名字。

activemq死信隊(duì)列怎么配置

 

2. individualDeadLetterStrategy

可以為queue和topic單獨(dú)指定兩個(gè)死信隊(duì)列。還可以為某個(gè)話題,單獨(dú)指定一個(gè)死信隊(duì)列。

activemq死信隊(duì)列怎么配置

activemq死信隊(duì)列怎么配置

activemq死信隊(duì)列怎么配置

“activemq死信隊(duì)列怎么配置”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!


文章名稱:activemq死信隊(duì)列怎么配置
文章源于:http://weahome.cn/article/jdipjh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部