Я получаю эту ошибку на стороне процессора: < /p>
2025-04-26 14:27:04,630 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel reportsqueue
2025-04-26 14:27:04,631 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-response
2025-04-26 14:27:04,632 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17007: Connection with RabbitMQ broker established for channel `reportsqueue`
2025-04-26 14:27:04,632 INFO [io.ver.rab.imp.RabbitMQClientImpl] (main) Starting rabbitmq client
2025-04-26 14:27:04,632 ERROR [io.ver.rab.imp.RabbitMQClientImpl] (executor-thread-1) Could not connect to rabbitmq: java.net.ConnectException: Connection refused
at java.base@21.0.6/sun.nio.ch.Net.pollConnect(Native Method)
at java.base@21.0.6/sun.nio.ch.Net.pollConnectNow(Net.java:682)
at java.base@21.0.6/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542)
at java.base@21.0.6/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592)
at java.base@21.0.6/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base@21.0.6/java.net.Socket.connect(Socket.java:751)
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:61)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1249)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1096)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.newConnection(RabbitMQClientImpl.java:160)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.connect(RabbitMQClientImpl.java:843)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.lambda$tryConnect$36(RabbitMQClientImpl.java:763)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$5(ContextImpl.java:205)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:270)
at io.vertx.core.impl.ContextImpl$1.execute(ContextImpl.java:221)
at io.vertx.core.impl.WorkerTask.run(WorkerTask.java:56)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:81)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:643)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base@21.0.6/java.lang.Thread.runWith(Thread.java:1596)
at java.base@21.0.6/java.lang.Thread.run(Thread.java:1583)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)
< /code>
У меня есть сервер Rabbitmq Manager, работающий на порте Localhost: 8085: 15672 для пользовательского интерфейса и порта AMQP на 5672. С моим приложением.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
rabbitmq.port=5672
rabbitmq.username=team1
rabbitmq.password=team1
mp.messaging.outgoing.order-response.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
mp.messaging.outgoing.order-response.rabbitmq.port=5672
mp.messaging.outgoing.order-response.rabbitmq.username=team1
mp.messaging.outgoing.order-response.rabbitmq.password=team1
mp.messaging.incoming.reportsqueue.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
mp.messaging.incoming.reportsqueue.rabbitmq.port=5672
mp.messaging.incoming.reportsqueue.rabbitmq.username=team1
mp.messaging.incoming.reportsqueue.rabbitmq.password=team1
< /code>
Мой производитель настроен аналогично Application.properties, но я не получаю никаких ошибок, как показано выше: < /p>
2025-04-26 03:01:09,439 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-response
2025-04-26 03:01:09,440 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-requests
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) team1-purchase-api 1.0.3 native (powered by Quarkus 3.20.0) started in 0.025s. Listening on: http://0.0.0.0:8080
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) Profile prod activated.
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) Installed features: [cdi, grpc-client, hibernate-orm, hibernate-reactive, hibernate-reactive-panache, hibernate-validator, kubernetes, messaging, messaging-rabbitmq, reactive-pg-client, rest, rest-jackson, smallrye-context-propagation, smallrye-openapi, swagger-ui, vertx]
< /code>
Это мой код на стороне процессора: < /p>
package team1_report;
import java.time.LocalDateTime;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import io.quarkus.hibernate.reactive.panache.common.WithTransaction;
import io.smallrye.mutiny.Uni;
import org.jboss.logging.Logger;
import io.vertx.core.json.JsonObject;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class ReportProcessor {
private static final Logger LOG = Logger.getLogger( ReportProcessor.class );
@Incoming("reportsqueue")
@Outgoing("order-response")
public String handleOrderRequest(String msg) {
LOG.info("Received order-request: " + msg);
try {
JsonObject json = new JsonObject(msg);
String orderId = json.getString("order_id");
Long customerId = json.getLong("customer_id");
Long productId = json.getLong("product_id");
Long quantity = json.getLong("quantity");
Double totalAmount = json.getDouble("total_amount");
String timestamp = LocalDateTime.now().toString();
Orders order = new Orders();
order.id = orderId;
order.customerId = customerId;
order.productId = productId;
order.quantity = quantity;
order.totalAmount = totalAmount;
order.timestamp = timestamp;
return persistOrder(order)
.onItem().transform(unused -> {
JsonObject response = new JsonObject();
response.put("orderID", orderId);
response.put("customerID", customerId);
response.put("productID", productId);
response.put("quantity", quantity);
response.put("totalAmount", totalAmount);
LOG.info("Saved order and emitted order-response: " + response.encodePrettily());
return response.encode();
})
.await().indefinitely();
} catch (Exception e) {
LOG.error("Error processing order-request", e);
return "NULL - ERROR";
}
}
@WithTransaction
public Uni persistOrder(Orders order){
return order.persist().replaceWithVoid();
}
}
< /code>
Вот мои работающие капсулы: < /p>
shubh@Mac Report-Microservice-Processor % kubectl get pods -n rabbitmq
NAME READY STATUS RESTARTS AGE
rabbitmq-0 1/1 Running 0 13h
shubh@Mac Report-Microservice-Processor % kubectl get pods
NAME READY STATUS RESTARTS AGE
team1-customer-68dcb85d4b-rqrbv 1/1 Running 8 (13h ago) 30h
team1-customer-client-665b678cd7-d79l7 1/1 Running 10 (22h ago) 2d15h
team1-customer-database-postgresql-0 1/1 Running 14 (22h ago) 4d22h
team1-purchase-api-94f4676cf-7pw48 1/1 Running 0 12h
team1-report-database-postgresql-0 1/1 Running 3 (22h ago) 29h
team1-report-processor-8696f4c5b4-c6vws 1/1 Running 0 3m13s
shubh@Mac Report-Microservice-Processor %
< /code>
edits: < /p>
Описание файла файла rabbitmq yaml. < /p>
shubh@Mac ~ % kubectl get svc team1-rabbitmq -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2025-04-26T16:10:49Z"
labels:
app.kubernetes.io/component: rabbitmq
app.kubernetes.io/name: team1-rabbitmq
app.kubernetes.io/part-of: rabbitmq
name: team1-rabbitmq
namespace: default
ownerReferences:
- apiVersion: rabbitmq.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: RabbitmqCluster
name: team1-rabbitmq
uid: 68cd3769-1bde-4967-91ab-4ef548cf9f7f
resourceVersion: "88607"
uid: 7a471fb6-8507-46fa-b40d-868aff3d0ccb
spec:
clusterIP: 10.43.136.31
clusterIPs:
- 10.43.136.31
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- appProtocol: amqp
name: amqp
port: 5672
protocol: TCP
targetPort: 5672
- appProtocol: http
name: management
port: 15672
protocol: TCP
targetPort: 15672
- appProtocol: prometheus.io/metrics
name: prometheus
port: 15692
protocol: TCP
targetPort: 15692
selector:
app.kubernetes.io/name: team1-rabbitmq
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
shubh@Mac ~ %
< /code>
Моя обновленная информация о стручке. < /p>
shubh@Mac ~ % kubectl get all
NAME READY STATUS RESTARTS AGE
pod/team1-customer-68dcb85d4b-rqrbv 1/1 Running 18 (118s ago) 2d23h
pod/team1-customer-client-665b678cd7-d79l7 1/1 Running 15 (12m ago) 4d8h
pod/team1-customer-database-postgresql-0 1/1 Running 19 (12m ago) 6d15h
pod/team1-purchase-api-94f4676cf-7pw48 1/1 Running 5 (12m ago) 2d5h
pod/team1-rabbitmq-server-0 1/1 Running 4 (12m ago) 40h
pod/team1-report-database-postgresql-0 1/1 Running 8 (12m ago) 2d22h
pod/team1-report-processor-769d55cdb6-j2756 1/1 Running 4 (2m ago) 31h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.43.0.1 443/TCP 53d
service/team1-customer ClusterIP 10.43.46.195 80/TCP,9000/TCP 6d15h
service/team1-customer-client ClusterIP 10.43.181.133 8081/TCP 7d4h
service/team1-customer-database-postgresql ClusterIP 10.43.172.107 5432/TCP 6d15h
service/team1-customer-database-postgresql-hl ClusterIP None 5432/TCP 6d15h
service/team1-purchase-api ClusterIP 10.43.46.133 80/TCP 3d
service/team1-rabbitmq ClusterIP 10.43.136.31 5672/TCP,15672/TCP,15692/TCP 40h
service/team1-rabbitmq-nodes ClusterIP None 4369/TCP,25672/TCP 40h
service/team1-report-database-postgresql ClusterIP 10.43.229.14 5432/TCP 2d22h
service/team1-report-database-postgresql-hl ClusterIP None 5432/TCP 2d22h
service/team1-report-processor ClusterIP 10.43.213.152 80/TCP 2d22h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/team1-customer 1/1 1 1 6d15h
deployment.apps/team1-customer-client 1/1 1 1 7d4h
deployment.apps/team1-purchase-api 1/1 1 1 3d
deployment.apps/team1-report-processor 1/1 1 1 2d22h
NAME DESIRED CURRENT READY AGE
replicaset.apps/team1-customer-55645666f7 0 0 0 4d7h
replicaset.apps/team1-customer-5769fcfb96 0 0 0 4d7h
replicaset.apps/team1-customer-5cb7894dd4 0 0 0 4d10h
replicaset.apps/team1-customer-5d4ccd8dd7 0 0 0 6d15h
replicaset.apps/team1-customer-6497d7b6f5 0 0 0 2d23h
replicaset.apps/team1-customer-68dcb85d4b 1 1 1 2d23h
replicaset.apps/team1-customer-6d74989c86 0 0 0 2d23h
replicaset.apps/team1-customer-7d9c58c994 0 0 0 6d15h
replicaset.apps/team1-customer-b75fbd57f 0 0 0 4d8h
replicaset.apps/team1-customer-client-5cd49cd966 0 0 0 4d8h
replicaset.apps/team1-customer-client-65ccf985b7 0 0 0 7d4h
replicaset.apps/team1-customer-client-665b678cd7 1 1 1 4d8h
replicaset.apps/team1-customer-client-6cf54cfb4d 0 0 0 7d3h
replicaset.apps/team1-purchase-api-5649cdcdf6 0 0 0 2d5h
replicaset.apps/team1-purchase-api-5dff7cb498 0 0 0 2d5h
replicaset.apps/team1-purchase-api-65bcd55fb8 0 0 0 2d15h
replicaset.apps/team1-purchase-api-65d8d5d4bc 0 0 0 2d15h
replicaset.apps/team1-purchase-api-6977b8564 0 0 0 2d19h
replicaset.apps/team1-purchase-api-78d85db5f7 0 0 0 2d19h
replicaset.apps/team1-purchase-api-796dcdcd7b 0 0 0 2d19h
replicaset.apps/team1-purchase-api-94f4676cf 1 1 1 2d5h
replicaset.apps/team1-purchase-api-c5dbfdb55 0 0 0 2d19h
replicaset.apps/team1-purchase-api-f4d7658c7 0 0 0 2d15h
replicaset.apps/team1-purchase-api-fcf98cfb8 0 0 0 2d19h
replicaset.apps/team1-report-processor-59d98d58fd 0 0 0 41h
replicaset.apps/team1-report-processor-667c5df867 0 0 0 41h
replicaset.apps/team1-report-processor-699445b644 0 0 0 41h
replicaset.apps/team1-report-processor-6bb7d46856 0 0 0 40h
replicaset.apps/team1-report-processor-769d55cdb6 1 1 1 31h
replicaset.apps/team1-report-processor-78b8c986c5 0 0 0 41h
replicaset.apps/team1-report-processor-796f4cbb56 0 0 0 31h
replicaset.apps/team1-report-processor-79869d9986 0 0 0 41h
replicaset.apps/team1-report-processor-858d85d77d 0 0 0 31h
replicaset.apps/team1-report-processor-8696f4c5b4 0 0 0 40h
replicaset.apps/team1-report-processor-8d74849d 0 0 0 40h
NAME READY AGE
statefulset.apps/team1-customer-database-postgresql 1/1 6d15h
statefulset.apps/team1-rabbitmq-server 1/1 40h
statefulset.apps/team1-report-database-postgresql 1/1 2d22h
NAME ALLREPLICASREADY RECONCILESUCCESS AGE
rabbitmqcluster.rabbitmq.com/team1-rabbitmq True True 40h
Подробнее здесь: https://stackoverflow.com/questions/795 ... h-rabbitmq