metaq spring配置
spring metaq
spring bean 配置
<bean id="sessionFactory" class="com.taobao.metamorphosis.client.extension.spring.MetaqMessageSessionFactoryBean">
<property name="zkConnect" value="192.168.137.2:2181"/>
<property name="zkSessionTimeoutMs" value="30000"/>
<property name="zkConnectionTimeoutMs" value="30000"/>
<property name="zkSyncTimeMs" value="5000"/>
</bean>
<bean id="messageBodyConverter" class="com.taobao.metamorphosis.client.extension.spring.JavaSerializationMessageBodyConverter"/>
<bean id ="metaqTemplate" class="com.taobao.metamorphosis.client.extension.spring.MetaqTemplate">
<property name="messageSessionFactory" ref="sessionFactory"/>
<property name="messageBodyConverter" ref="messageBodyConverter"/>
</bean>
使用
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.taobao.metamorphosis.client.extension.spring.MessageBuilder;
import com.taobao.metamorphosis.client.extension.spring.MetaqTemplate;
@Service("topicService")
public class TopicService {
@Autowired
@Qualifier("metaqTemplate")
private MetaqTemplate metaqTemplate;
public MetaqTemplate getMetaqTemplate() {
return metaqTemplate;
}
public void setMetaqTemplate(MetaqTemplate metaqTemplate) {
this.metaqTemplate = metaqTemplate;
}
public void sendMsg(String topic, String msg) {
try {
metaqTemplate.send(MessageBuilder.withTopic(topic).withBody(new Date()));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
轉載: http://blog.csdn.net/luyee2010/article/details/40313883
相關文章
- metaq最佳實踐
- metaq原理簡介
- metaq入門部署到實戰
- 中介軟體、MetaQ入門學習
- 淘寶分散式訊息中介軟體Metaq 1.4.3分散式
- 配置SpringSpring
- Spring配置Spring
- Spring的DataSource配置、將Hibernate配置全部寫到Spring配置Spring
- Spring Boot & 配置Spring Boot
- Spring配置注入Spring
- Spring RMI配置Spring
- Spring 配置 ActiveMQSpringMQ
- Spring Boot + Mybatis + Spring MVC環境配置(三):DataSource配置Spring BootMyBatisMVC
- Spring Boot:Spring Boot配置MybatisSpring BootMyBatis
- Spring Boot + Mybatis + Spring MVC環境配置(二):Mybatis Generator配置Spring BootMyBatisMVC
- 使用Maven配置SpringMavenSpring
- spring boot 配置 JPASpring Boot
- Spring IOC XML配置SpringXML
- MyBatis Spring SqlSessionFactoryBean 配置MyBatisSpringSQLSessionBean
- Spring MVC DispatcherServlet 配置SpringMVCServlet
- Spring中配置WebSocketSpringWeb
- Spring 配置繼承Spring繼承
- Spring Boot核心配置Spring Boot
- Spring配置事務Spring
- Spring--Java配置SpringJava
- Spring配置說明Spring
- spring相關配置Spring
- Spring配置之OpenSessionInViewFilterSpringSessionViewFilter
- Spring配置相關Spring
- Spring 的容器配置Spring
- 訊息中介軟體Notify和MetaQ-阿里中介軟體阿里
- Spring Boot:Spring Boot配置SwaggerSpring BootSwagger
- Spring Boot Security配置教程Spring Boot
- Spring Boot日誌配置Spring Boot
- Spring Boot 配置檔案Spring Boot
- Spring(使用註解配置)Spring
- Spring-讀取配置Spring
- Spring檔案最全配置Spring