spring集成多个rabbitMQ
转自:https://blog.csdn.net/zz775854904/article/details/81092892
MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法。应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。消息传递指的是程序之间通过在消息中发送数据进行通信,而不是通过直接调用彼此来通信,直接调用通常是用于诸如远程过程调用的技术。排队指的是应用程序通过 队列来通信。队列的使用除去了接收和发送应用程序同时执行的要求..
开始正题!
在开发之前需要下载rabbitmq, 而在rabbitmq安装之前,童鞋们需要安装erlang, 因为rabbitmq是用erlang写的.
安装完毕之后,我们建立一个maven项目.然后我们开始配置项目.
- <!-- spring版本号 -->
- <spring.version>3.2.8.RELEASE</spring.version>
- <!-- 添加Spring依赖 -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aspects</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>${spring.version}</version>
- </dependency>
由于是spring整合,我们需要加入spring的依赖.
- <!--rabbitmq依赖 -->
- <dependency>
- <groupId>org.springframework.amqp</groupId>
- <artifactId>spring-rabbit</artifactId>
- <version>1.3.5.RELEASE</version>
- </dependency>
依赖加好了之后, 我们需要定义消息生产者和消息发送者.
由于exchange有几种,这里我只测试了两种, 通过分别定义两个exchange去绑定direct和topic..
首先, 定义消息生产者, 通过配置将template链接connect-factory并注入到代码中使用.
- package com.chris.producer;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.amqp.core.AmqpTemplate;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.io.IOException;
- /**
- * Created by wuxing on 2016/9/21.
- */
- @Service
- public class MessageProducer {
- private Logger logger = LoggerFactory.getLogger(MessageProducer.class);
- @Resource(name="amqpTemplate")
- private AmqpTemplate amqpTemplate;
- @Resource(name="amqpTemplate2")
- private AmqpTemplate amqpTemplate2;
- public void sendMessage(Object message) throws IOException {
- logger.info("to send message:{}", message);
- amqpTemplate.convertAndSend("queueTestKey", message);
- amqpTemplate.convertAndSend("queueTestChris", message);
- amqpTemplate2.convertAndSend("wuxing.xxxx.wsdwd", message);
- }
- }
然后我们定义消息消费者, 这里,我定义了三个消费者, 通过监听消息队列, 分别接受各自所匹配的消息.
第一个消费者, 接受direct的消息, 他的exchange为exchangeTest, rout-key为queueTestKey
- package com.chris.consumer;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.amqp.core.Message;
- import org.springframework.amqp.core.MessageListener;
- /**
- * Created by wuxing on 2016/9/21.
- */
- public class MessageConsumer implements MessageListener {
- private Logger logger = LoggerFactory.getLogger(MessageConsumer.class);
- @Override
- public void onMessage(Message message) {
- logger.info("consumer receive message------->:{}", message);
- }
- }
第二个消费者, 接受direct的消息(为了测试一个exchange可以发送多个消息), 他的exchange为exchangeTest, rout-key为queueTestChris.
- package com.chris.consumer;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.amqp.core.Message;
- import org.springframework.amqp.core.MessageListener;
- /**
- * Created by wuxing on 2016/9/21.
- */
- public class ChrisConsumer implements MessageListener {
- private Logger logger = LoggerFactory.getLogger(ChrisConsumer.class);
- @Override
- public void onMessage(Message message) {
- logger.info("chris receive message------->:{}", message);
- }
- }
第三个消费者, 接受topic的消息他的exchange为exchangeTest2, pattern为wuxing.*.. 网上说.*可以匹配一个, .#可以匹配一个或多个..但是笔者好像两个都试了..都可以匹配一个或多个..不知道什么鬼...
- package com.chris.consumer;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.amqp.core.Message;
- import org.springframework.amqp.core.MessageListener;
- /**
- * Created by wuxing on 2016/9/21.
- */
- public class WuxingConsumer implements MessageListener {
- private Logger logger = LoggerFactory.getLogger(WuxingConsumer.class);
- @Override
- public void onMessage(Message message) {
- logger.info("wuxing receive message------->:{}", message);
- }
- }
然后就是关键的地方了..rabbit整合spring的配置文件.
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/rabbit
- http://www.springframework.org/schema/rabbit/spring-rabbit-1.2.xsd">
- <!--配置connection-factory,指定连接rabbit server参数 -->
- <rabbit:connection-factory id="connectionFactory"
- username="guest" password="guest" host="localhost" port="5672" />
- <!--定义rabbit template用于数据的接收和发送 -->
- <rabbit:template id="amqpTemplate" connection-factory="connectionFactory"
- exchange="exchangeTest"/>
- <!--通过指定下面的admin信息,当前producer中的exchange和queue会在rabbitmq服务器上自动生成 -->
- <rabbit:admin id="connectAdmin" connection-factory="connectionFactory"/>
- <!--定义queue -->
- <rabbit:queue name="queueTest" durable="true" auto-delete="false" exclusive="false" declared-by="connectAdmin"/>
- <!-- 定义direct exchange,绑定queueTest -->
- <rabbit:direct-exchange name="exchangeTest" durable="true" auto-delete="false" declared-by="connectAdmin">
- <rabbit:bindings>
- <rabbit:binding queue="queueTest" key="queueTestKey"></rabbit:binding>
- </rabbit:bindings>
- </rabbit:direct-exchange>
- <!-- 消息接收者 -->
- <bean id="messageReceiver" class="com.chris.consumer.MessageConsumer"></bean>
- <!-- queue litener 观察 监听模式 当有消息到达时会通知监听在对应的队列上的监听对象-->
- <rabbit:listener-container connection-factory="connectionFactory">
- <rabbit:listener queues="queueTest" ref="messageReceiver"/>
- </rabbit:listener-container>
- <!--定义queue -->
- <rabbit:queue name="queueChris" durable="true" auto-delete="false" exclusive="false" declared-by="connectAdmin"/>
- <!-- 定义direct exchange,绑定queueTest -->
- <rabbit:direct-exchange name="exchangeTest" durable="true" auto-delete="false" declared-by="connectAdmin">
- <rabbit:bindings>
- <rabbit:binding queue="queueChris" key="queueTestChris"></rabbit:binding>
- </rabbit:bindings>
- </rabbit:direct-exchange>
- <!-- 消息接收者 -->
- <bean id="receiverChris" class="com.chris.consumer.ChrisConsumer"></bean>
- <!-- queue litener 观察 监听模式 当有消息到达时会通知监听在对应的队列上的监听对象-->
- <rabbit:listener-container connection-factory="connectionFactory">
- <rabbit:listener queues="queueChris" ref="receiverChris"/>
- </rabbit:listener-container>
- <!-- 分隔线 -->
- <!--配置connection-factory,指定连接rabbit server参数 -->
- <rabbit:connection-factory id="connectionFactory2"
- username="guest" password="guest" host="localhost" port="5672"/>
- <!--定义rabbit template用于数据的接收和发送 -->
- <rabbit:template id="amqpTemplate2" connection-factory="connectionFactory2"
- exchange="exchangeTest2"/>
- <!--通过指定下面的admin信息,当前producer中的exchange和queue会在rabbitmq服务器上自动生成 -->
- <rabbit:admin id="connectAdmin2" connection-factory="connectionFactory2"/>
- <!--定义queue -->
- <rabbit:queue name="queueWuxing" durable="true" auto-delete="false" exclusive="false" declared-by="connectAdmin2"/>
- <!-- 定义direct exchange,绑定queueTest -->
- <rabbit:topic-exchange name="exchangeTest2" durable="true" auto-delete="false" declared-by="connectAdmin2">
- <rabbit:bindings>
- <rabbit:binding queue="queueWuxing" pattern="wuxing.*"></rabbit:binding>
- </rabbit:bindings>
- </rabbit:topic-exchange>
- <!-- 消息接收者 -->
- <bean id="recieverWuxing" class="com.chris.consumer.WuxingConsumer"></bean>
- <!-- queue litener 观察 监听模式 当有消息到达时会通知监听在对应的队列上的监听对象-->
- <rabbit:listener-container connection-factory="connectionFactory2" >
- <rabbit:listener queues="queueWuxing" ref="recieverWuxing"/>
- </rabbit:listener-container>
- </beans>
这里,有个问题笔者研究了好久...就是如何定义两个exchange, 一开始一直不成功..直到找到了一篇国外的文章才解决...
定义两个exchange的时候, 需要用到declared-by..
而这个必须要引入下面的这个申明, 才有..
- http://www.springframework.org/schema/rabbit
- http://www.springframework.org/schema/rabbit/spring-rabbit-1.2.xsd">
文件中大概的配置解释一下.
connect-factory进行连接rabbitmq服务.
template用于连接factory并指定exchange, 这上面还能直接指定rout-key.
admin相当于一个管理员的角色..可以将exchange和queue进行管理,
queue和topic-exchange分别定义队列和路由器, 这里需要用declared-by指定管理员,从而连接到相应的factory.
listener-container用于消费者的监听(其实,rabbit配置中是可以指定某个类的某个方法的, 但是笔者失败了, 还在试验中...)
这里还有一个问题...需要大家注意..
当一个exchange绑定了一种类型之后, 这个exchange在配置就不能再换成另一种了.会一直报错, received 'direct' but current is 'topic' 类似这种..
笔者这个也是被坑了若干时间去找问题...
然后贴下spring的基本配置
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
- <import resource="classpath*:rabbitmq.xml" />
- <!-- 扫描指定package下所有带有如@controller,@services,@resource,@ods并把所注释的注册为Spring Beans -->
- <context:component-scan base-package="com.chris.consumer, com.chris.producer" />
- <!-- 激活annotation功能 -->
- <context:annotation-config />
- <!-- 激活annotation功能 -->
- <context:spring-configured />
- </beans>
然后是单元测试类, 这里通过输出100-1慢慢递减,去观察控制台消费者接收消息的情况.
- package com.chris;
- import com.chris.producer.MessageProducer;
- import org.junit.Before;
- import org.junit.Test;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- /**
- * Created by wuxing on 2016/9/21.
- */
- public class MessageTest {
- private Logger logger = LoggerFactory.getLogger(MessageTest.class);
- private ApplicationContext context = null;
- @Before
- public void setUp() throws Exception {
- context = new ClassPathXmlApplicationContext("application.xml");
- }
- @Test
- public void should_send_a_amq_message() throws Exception {
- MessageProducer messageProducer = (MessageProducer) context.getBean("messageProducer");
- int a = 100;
- while (a > 0) {
- messageProducer.sendMessage("Hello, I am amq sender num :" + a--);
- try {
- //暂停一下,好让消息消费者去取消息打印出来
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
然后控制台的结果如下(这里只贴出关键信息, 其他配置的log的省略了)
- 2016-09-22 16:15:00,330 [main] INFO [com.chris.producer.MessageProducer] - to send message:Hello, I am amq sender num :100
- 2016-09-22 16:15:00,348 [main] DEBUG [org.springframework.amqp.rabbit.connection.CachingConnectionFactory] - Creating cached Rabbit Channel from AMQChannel(amqp://guest@127.0.0.1:5672/,3)
- 2016-09-22 16:15:00,348 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,3)
- 2016-09-22 16:15:00,349 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Publishing message on exchange [exchangeTest], routingKey = [queueTestKey]
- 2016-09-22 16:15:00,357 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,3)
- 2016-09-22 16:15:00,358 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Publishing message on exchange [exchangeTest], routingKey = [queueTestChris]
- 2016-09-22 16:15:00,368 [main] DEBUG [org.springframework.amqp.rabbit.connection.CachingConnectionFactory] - Creating cached Rabbit Channel from AMQChannel(amqp://guest@127.0.0.1:5672/,2)
- 2016-09-22 16:15:00,369 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,2)
- 2016-09-22 16:15:00,369 [main] DEBUG [org.springframework.amqp.rabbit.core.RabbitTemplate] - Publishing message on exchange [exchangeTest2], routingKey = [wuxing.xxxx.wsdwd]
- 2016-09-22 16:15:00,370 [pool-1-thread-6] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Storing delivery for Consumer: tags=[[amq.ctag-hyW85GZHk-AHLLFJUmNLDQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), acknowledgeMode=AUTO local queue size=0
- 2016-09-22 16:15:00,372 [SimpleAsyncTaskExecutor-1] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Received message: (Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest, receivedRoutingKey=queueTestKey, deliveryTag=1, messageCount=0])
- 2016-09-22 16:15:00,373 [SimpleAsyncTaskExecutor-1] INFO [com.chris.consumer.MessageConsumer] - consumer receive message------->:(Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest, receivedRoutingKey=queueTestKey, deliveryTag=1, messageCount=0])
- 2016-09-22 16:15:00,374 [SimpleAsyncTaskExecutor-1] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Retrieving delivery for Consumer: tags=[[amq.ctag-hyW85GZHk-AHLLFJUmNLDQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), acknowledgeMode=AUTO local queue size=0
- 2016-09-22 16:15:00,379 [pool-2-thread-4] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Storing delivery for Consumer: tags=[[amq.ctag-T-c1red0T_HHyCFfpXLYIQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), acknowledgeMode=AUTO local queue size=0
- 2016-09-22 16:15:00,381 [SimpleAsyncTaskExecutor-1] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Received message: (Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest2, receivedRoutingKey=wuxing.xxxx.wsdwd, deliveryTag=1, messageCount=0])
- 2016-09-22 16:15:00,382 [SimpleAsyncTaskExecutor-1] INFO [com.chris.consumer.WuxingConsumer] - wuxing receive message------->:(Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest2, receivedRoutingKey=wuxing.xxxx.wsdwd, deliveryTag=1, messageCount=0])
- 2016-09-22 16:15:00,383 [SimpleAsyncTaskExecutor-1] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Retrieving delivery for Consumer: tags=[[amq.ctag-T-c1red0T_HHyCFfpXLYIQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), acknowledgeMode=AUTO local queue size=0
- 2016-09-22 16:15:00,396 [pool-1-thread-5] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Storing delivery for Consumer: tags=[[amq.ctag-h5ERpaWrnqmkNhbfM7S8Ww]], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,2), acknowledgeMode=AUTO local queue size=0
- 2016-09-22 16:15:00,397 [SimpleAsyncTaskExecutor-1] DEBUG [org.springframework.amqp.rabbit.listener.BlockingQueueConsumer] - Received message: (Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest, receivedRoutingKey=queueTestChris, deliveryTag=1, messageCount=0])
- 2016-09-22 16:15:00,398 [SimpleAsyncTaskExecutor-1] INFO [com.chris.consumer.ChrisConsumer] - chris receive message------->:(Body:'Hello, I am amq sender num :100'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=exchangeTest, receivedRoutingKey=queueTestChris, deliveryTag=1, messageCount=0])
我们可以看到生产者有发出一个信息, 然后发布在了三个通道上.
1. on exchange [exchangeTest] , routingKey = [queueTestKey]
2. on exchange [exchangeTest] , routingKey = [queueTestChris]
3. on exchange [exchangeTest2] , routingKey = [wuxing.xxxx.wsdwd]
然后三个消费者分别收到了他们的消息..至此, 整个test就结束了.
对项目有兴趣的童鞋可以拿项目的源码玩一玩 源码在这里
spring集成多个rabbitMQ的更多相关文章
- Spring集成RabbitMQ-使用RabbitMQ更方便
如果提到Spring,你脑海中对他的印象还停留在SSH三大框架之一,那或许你该好好重新认识这个家伙. 在IT技术日新月异的今天,他还能让你忘不了并与他朝夕相处,他,肯定有自己的绝活.如今他早已经不是孤 ...
- Spring集成RabbiMQ-Spring AMQP新特性
上一篇<Spring集成RabbitMQ-使用RabbitMQ更方便>中,我们只需要添加响应jar的依赖,就可以写一个Spring集成RabbitMQ下非常简单收发消息的程序. 我们使用的 ...
- rabbitMQ第五篇:Spring集成RabbitMQ
前面几篇讲解了如何使用rabbitMq,这一篇主要讲解spring集成rabbitmq. 首先引入配置文件org.springframework.amqp,如下 <dependency> ...
- RabbitMQ安装和使用(和Spring集成)
一.安装Rabbit MQ Rabbit MQ 是建立在强大的Erlang OTP平台上,因此安装Rabbit MQ的前提是安装Erlang.通过下面两个连接下载安装3.2.3 版本: 下载并安装 E ...
- RabbitMQ第四篇:Spring集成RabbitMQ
前面几篇讲解了如何使用rabbitMq,这一篇主要讲解spring集成rabbitmq. 首先引入配置文件org.springframework.amqp,如下 <dependency> ...
- 消息中间件系列四:RabbitMQ与Spring集成
一.RabbitMQ与Spring集成 准备工作: 分别新建名为RabbitMQSpringProducer和RabbitMQSpringConsumer的maven web工程 在pom.xml文 ...
- RabbitMQ与Spring集成
RabbitMQ服务端安装: https://blog.csdn.net/hzw19920329/article/details/53156015 与Spring集成 https://www.cnbl ...
- RabbitMQ与spring集成,配置完整的生产者和消费者
RabbitMQ与AMQP协议详解可以看看这个 http://www.cnblogs.com/frankyou/p/5283539.html 下面是rabbitMQ和spring集成的配置,我配置了二 ...
- RabbitMQ入门教程(十六):RabbitMQ与Spring集成
原文:RabbitMQ入门教程(十六):RabbitMQ与Spring集成 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https: ...
随机推荐
- 【Quartz】Quartz将Job保存在数据库中所需表的说明
QRTZ_CALENDARS 以 Blob 类型存储 Quartz 的 Calendar 信息 QRTZ_CRON_TRIGGERS 存储 Cron Trigger,包括 Cron表达式和时区信息 ...
- Dataframe 新增一列, apply 通用方法
df['c'] = df.apply(lambda row: 1 if row['a'] < 0 and row['b'] > 0 else 0, axis=1) apply 是一个好方法 ...
- sys目录下常用文件汇总
1. /sys/kernel/debug/gpio 可以实时反馈系统中感兴趣的gpio引脚的状态 root@g6s:/sys/kernel/debug# cat gpio gpiochip7: GPI ...
- asp.net 导出excel的一种方法
项目用到的一种导出excel 的方法予以记录:(具体的业务类可更具情况替换使用) protected void Export(string filename, List<ComponentCon ...
- mysql常用的聚合函数
GROUP BY(聚合)函数本章论述了用于一组数值操作的 group (集合)函数.除非另作说明, group 函数会忽略 NULL 值. 假如你在一个不包含 ROUP BY子句的语句中使用一个 gr ...
- Spark的启动进程详解
Master和Worker是执行任务之前存在的进程 (类似于公司) Driver和Excutor是任务执行之后存在的进程(类似于公司接到项目后才成立的项目小组) 启动步骤: 启动Master资源管理进 ...
- gl attribute和uniform的用法
gl attribute和uniform的用法 http://blog.csdn.net/jackers679/article/details/6848085 attribute attribu ...
- Server对象,HttpServerUtility类,获取服务器信息
在Asp.net WebForm中,Server对象是HttpServerUtility类的实例.看下图: 而在Asp.net MVC中,Server对象是HttpServerUtilityBase对 ...
- AngularJS通过$location获取及改变当前页面的URL
本文中获取与修改的URL以 ‘http://172.16.0.88:8100/#/homePage?id=10&a=100' 这个路径为例: 一. 获取url的相关方法(不修改URL): 1. ...
- 【python】网络编程-UDP协议套接字
服务器端: #!/usr/bin/env python from socket import * from time import ctime HOST = '' PORT = 21567 BUFSI ...