我有一个使用rabbitmq代理的客户端服务器应用程序.客户端连接到rabbitmq并将消息发送到服务器.在某些时候,如果服务器决定不应该将此客户端连接到rabbitmq,我希望能够强制断开客户端与rabbitmq边界的连接.请注意,在我的情况下,我不想发送消息给客户端断开连接,在服务器端我想强制断开这个客户端与rabbitmq.
找不到api这样做.任何帮助都是适当的.
MassTransit.3.1.2 MassTransit.Autofac.3.1.1 MassTransit.RabbitMQ.3.1.1 RabbitMQ.Client.3.6.0 Topshelf.3.3.1
一个 Topshelf Windows 服务,创建一个像这样的总线实例:
var builder = new ContainerBuilder();
builder.RegisterConsumers(Assembly.GetExecutingAssembly());
builder.Register<IBusControl>(context =>
{
return Bus.Factory.CreateUsingRabbitMq(rbmq =>
{
var host = rbmq.Host(new Uri("rabbitmq://" + BusConfig.Instance.Host + ":" + BusConfig.Instance.Port + "/" + BusConfig.Instance.VHost), h =>
{
h.Username(BusConfig.Instance.UserName);
h.Password(BusConfig.Instance.Password);
});
rbmq.UseJsonSerializer();
rbmq.UseNLog();
rbmq.ReceiveEndpoint(BusConfig.Instance.Queue, edp =>
{
edp.UseRetry(Retry.Incremental(5, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5)));
edp.LoadFrom(context);
});
});
}).SingleInstance().As<IBusControl>().As<IBus>();
return builder.Build().Resolve<IBusControl>();
Run Code Online (Sandbox Code Playgroud)
像这样的一个控制台应用程序?
var bus = Bus.Factory.CreateUsingRabbitMq(rbmq =>
{
var host = rbmq.Host(new Uri("rabbitmq://" + BusConfig.Instance.Host + ":" + BusConfig.Instance.Port + "/" + BusConfig.Instance.VHost), …Run Code Online (Sandbox Code Playgroud) 目前,我正在使用https://github.com/php-amqplib/php-amqplib并且我在这个存储库中阅读了很多示例,但我仍然不明白如何从队列中获取所有消息?
我只需要接收一些消息,按值对它们进行分组并执行一个操作。
是否可以使用 RabbitMQ?
我如何在 php 中实现它?
我正在开发.NET Core Web API,我有一个上传excel文件的操作,这应该读取文件,处理它并将内容保存到SQL Server数据库,当然可以插入一行excel多个表,之前创建的表结构用于存储所有数据,这不是简单的转储或批处理过程.
除了API,我们为客户端开发了一个Angular 4应用程序,因此从Angular组件上传文件,到目前为止一切都很好
问题是,有人可以上传一个非常巨大的文件的API,我们正在考虑的一种方式来处理后台进程的文件,因此客户端用户只会选择文件并点击上传文件时,API应该排队的文件后台任务将处理文件并执行需要执行的操作以保存到数据库.
所有基础设施(API,客户端和数据库)都将部署到Linux环境中.问题是:这是一个好方法吗? linux中有什么东西可以用吗?
我已经读过关于RabbitMQ的内容,但我不确定它,或者是否有更好或更适合这种情况的东西.
你们怎么处理类似的情况?
感谢您的回答和建议.
我只是在与 RabbitMQ 一起使用,然后尝试向它发送一个 json 有效负载。不幸的是我收到错误:
{"error":"bad_request","reason":"payload_not_string"}
Run Code Online (Sandbox Code Playgroud)
我在某处阅读了我需要使用的内容,"content_type": "application/json"但这也无济于事。
这是我要发送的正文:
{
"properties": {
"delivery_mode": 2,
"content_type": "application/json"
},
"routing_key": "git",
"payload": {
"action": "created",
"comment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
"id": 11056394
}
},
"payload_encoding": "string"
}
Run Code Online (Sandbox Code Playgroud)
和完整的卷曲:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:Basic Z3Vlc3Q6Z3Vlc3Q=" \
-d \
'{
"properties": {
"delivery_mode": 2,
"content_type": "application/json"
},
"routing_key": "git",
"payload": {
"action": "created",
"comment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
"id": 11056394
}
},
"payload_encoding": "string"
}' \
'http://localhost:8090/api/exchanges/%2f/amq.topic/publish'
Run Code Online (Sandbox Code Playgroud)
是否可以发送 json …
发送到我的队列的第一条消息总是失败。从第二个开始,一切正常!
不确定这是否可读,所以:
Created new connection: rabbitConnectionFactory#1b940034:0/SimpleConnection@2c52fbff [delegate=amqp://guest@10.0.0.10:5672/, localPort= 36370]
Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'auto_delete' for exchange 'rabbitmq_exchange' in vhost '/': received 'false' but current is 'true', class-id=40, method-id=10)
Run Code Online (Sandbox Code Playgroud)
我不确定为什么会发生这种情况,因为我每次都在新的 VM(AWS EC2 实例)上启动它。“电流是真的”怎么可能?
我想在 Spring Boot 发布者中配置错误:
不确定这是否可读,所以:
@Configuration
public class RabbitMqConfig {
@Bean
Queue queue() {
return new Queue(System.getenv("RABBITMQ_QUEUE_NAME"), true,false, false);
}
@Bean
DirectExchange exchange() {
return new DirectExchange(System.getenv("RABBITMQ_EXCHANGE_NAME"), true, false);
}
@Bean
Binding binding(Queue queue, DirectExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(System.getenv("RABBITMQ_ROUTING_KEY"));
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring AMQP开发一个消费者应用程序,它接收来自RabbitMQ的消息.宣布了一个主题交换.要连接到Rabbit,我创建一个空名称的队列,因为代理将提供自动队列名称,请参阅规范:
@Bean
public TopicExchange exchange() {
TopicExchange topicExchange = new TopicExchange(topicExchangeName);
topicExchange.setShouldDeclare(false);
return topicExchange;
}
@Bean
public Queue queue() {
return new Queue("", queueDurable, queueExclusive, queueAutoDelete, queueParameters);
}
@Bean
public Binding binding(Queue queue, TopicExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(routingKey);
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用Spring Integration Java DSL 配置AMQP入站通道适配器时:
@Autowired
private Queue queue;
@Bean
public IntegrationFlow amqpInbound(ConnectionFactory connectionFactory) {
return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, queue))
.handle(m -> System.out.println(m.getPayload()))
.get();
}
Run Code Online (Sandbox Code Playgroud)
我得到一个错误'queueName'不能为null或为空
2018-05-25 13:39:15.080 ERROR 14636 --- [erContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer …Run Code Online (Sandbox Code Playgroud) 我无法将 node.js 应用程序与 rabbit-mq 服务器连接。Postgres 已正确连接。我不知道为什么我的连接被拒绝。
version: "3"
networks:
app-tier:
driver: bridge
services:
db:
image: postgres
environment:
- POSTGRES_USER=dockerDBuser
- POSTGRES_PASSWORD=dockerDBpass
- POSTGRES_DB=performance
ports:
- "5433:5432"
volumes:
- ./pgdata:/var/lib/postgresql/data
networks:
- app-tier
rabbitmq:
image: rabbitmq:3.6.14-management
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:5672"]
interval: 30s
timeout: 10s
retries: 5
ports:
- "0.0.0.0:5672:5672"
- "0.0.0.0:15672:15672"
networks:
- app-tier
app:
build: .
depends_on:
- rabbitmq
- db
links:
- rabbitmq
- db
command: npm run startOrc
environment:
DATABASE_URL: postgres://dockerDBuser:dockerDBpass@db:5432/asdf
restart: on-failure
networks:
- app-tier …Run Code Online (Sandbox Code Playgroud) I'm trying to set up a service which listens to a RabbitMQ server and I've set up code using the RabbitMQ Sample code from Github, which includes the following try-with-resources block
try (Connection connection = factory.newConnection();
Channel channel = connection.createChannel()) {
// code here
}
Run Code Online (Sandbox Code Playgroud)
When I use the same code and build and run this service using java -cp myJar.jar MyService, it just starts and ends immediately (and echo $? returns 0)
However, if I replace the …
rabbitmq ×10
.net-core ×1
angular ×1
asp.net-core ×1
docker ×1
java ×1
java-11 ×1
masstransit ×1
php ×1
pika ×1
python-pika ×1
queue ×1
servicebus ×1
soap ×1
spring-amqp ×1
try-catch ×1