当前位置: 首页 > news >正文

网站优化哪家好晚上免费b站软件

网站优化哪家好,晚上免费b站软件,深圳建筑业协会,国家高职示范校建设网站原始状态的 activemq-client sdk 集成非常方便&#xff0c;也更适合定制。就是有些同学&#xff0c;可能对原始接口会比较陌生&#xff0c;会希望有个具体的示例。 <dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-client&l…

原始状态的 activemq-client sdk 集成非常方便,也更适合定制。就是有些同学,可能对原始接口会比较陌生,会希望有个具体的示例。

<dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-client</artifactId><version>${activemq.version}</version>
</dependency><dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-pool</artifactId><version>${activemq.version}</version>
</dependency>

希望更加简化使用的同学,可以使用:

activemq-solon-cloud-plugin (使用更简单,定制性弱些)

1、添加集成配置

先使用 Solon 初始器 先生成一个 Solon Web 模板项目,然后添加上面的 activemq-client 依赖。再做个配置约定(也可按需定义):

  • “solon.activemq”,作为配置前缀
    • “properties”,作为公共配置
    • “producer”,作为生态者专属配置(估计用不到)
    • “consumer”,作为消费者专属配置(估计用不到)

具体的配置属性,参考自:ActiveMQConnectionFactory

solon.app:name: "demo-app"group: "demo"# 配置可以自由定义,与 @Bean 代码对应起来即可(以下为参考)
solon.activemq:properties:  #公共配置(配置项,参考:ActiveMQConnectionFactory)brokerURL: "failover:tcp://localhost:61616"redeliveryPolicy:initialRedeliveryDelay: 5000backOffMultiplier: 2useExponentialBackOff: truemaximumRedeliveries: -1maximumRedeliveryDelay: 3600_000

添加 java 配置器

@Configuration
public class ActivemqConfig {@Bean(destroyMethod = "stop")public Connection client(@Inject("${solon.activemq.properties}") Props common) throws Exception {String brokerURL = (String) common.remove("brokerURL");String userName = (String) common.remove("userName");String password = (String) common.remove("password");ActiveMQConnectionFactory factory;if (Utils.isEmpty(userName)) {factory = new ActiveMQConnectionFactory(brokerURL);} else {factory = new ActiveMQConnectionFactory(brokerURL, userName, password);}//绑定额外的配置并创建连接Connection connection = common.bindTo(factory).createConnection();connection.start();return connection;}@Beanpublic IProducer producer(Connection connection) throws Exception {return new IProducer(connection);}@Beanpublic void consumer(Connection connection,MessageListener messageListener) throws Exception {Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);Destination destination = session.createTopic("topic.test");MessageConsumer consumer = session.createConsumer(destination);consumer.setMessageListener(messageListener);}
}

activemq 的消息发送的代码比较复杂,所以我们可以做个包装处理(用于上面的配置构建),临时命名为 IProducer:

public class IProducer {private Connection connection;public IProducer(Connection connection) {this.connection = connection;}public void send(String topic, MessageBuilder messageBuilder) throws JMSException {Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);Destination destination = session.createTopic(topic);MessageProducer producer = session.createProducer(destination);producer.send(destination, messageBuilder.build(session));}@FunctionalInterfacepublic static interface MessageBuilder {Message build(Session session) throws JMSException;}
}

3、代码应用

发送(或生产),这里代控制器由用户请求再发送消息(仅供参考):

@Controller
public class DemoController {@Injectprivate IProducer producer;@Mapping("/send")public void send(String msg) throws Exception {//发送producer.send("topic.test", s -> s.createTextMessage("test"));}
}

监听(或消费),这里采用订阅回调的方式:(仅供参考)

@Component
public class DemoMessageListener implements MessageListener {@Overridepublic void onMessage(Message message) {System.out.println(message);RunUtil.runAndTry(message::acknowledge);}
}
http://www.hrbkazy.com/news/46535.html

相关文章:

  • 十堰秦楚网 十堰新闻门户网站网店如何引流与推广
  • 网站建设mrd文档模板惠州seo推广外包
  • app应用网站源码深圳网络营销策划有限公司
  • 南京做网站询南京乐识怎么做网站教程
  • 优惠券网站开发哪家好自己怎么做网站推广
  • 网站建设费用推荐网络专业手机网站模板建站
  • 公司门户网站怎么做外贸网站制作公司
  • 朝阳网站建设公司搜索竞价
  • 网页设计个人网站怎么做百度联盟注册
  • oem网站建设源码现在最火的推广平台
  • 公司网站怎么建站最近发生的新闻大事
  • 株洲做网站的公司今日国内新闻大事件
  • 品牌网站建设熊掌号免费网站安全软件大全游戏
  • 电商网站开发模块今日时政新闻
  • 济南做网站得多少钱武汉seo全网营销
  • 宜宾市做网站多少钱济宁seo推广
  • 遵义网站制作小程序相关搜索优化软件
  • 网站制作的书籍网站关键词优化教程
  • 济南哪家公司可以做网站百度排行榜小说
  • mysql 连接wordpress南宁网站优化
  • 四川建设厅官方网站证书查询百度提交
  • 网站设计师是什么专业搜索引擎推广的三种方式
  • 网络公司 开发网站网络平台推广广告费用
  • 新开传奇网站超变下列哪些店铺适合交换友情链接
  • 嘉兴网站制作策划刚刚济南发通知
  • 西宁做网站君博推荐网站建设开发简介
  • 怎样登录住房和城乡建设部网站社群营销方案
  • 网站建设业务范围湖南网络优化服务
  • 做化工外贸需要那些网站网站推广排名教程
  • pbootcms万能授权码淘宝seo搜索排名优化