illegalstateexception:无法订阅处理器已终止

h79rfbju  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(231)

我创建了一个新的eventhub并尝试将消息发布到eventhuba。尝试向eventhub发送消息时,出现以下错误:
java.lang.illegalstateexception:命名空间[xx]实体路径[xx]:无法订阅。处理器已终止于com.azure.core.amqp.implementation.amqpchannelprocessor.subscribe(amqpchannelprocessor.java:217)
下面是我正在使用的代码片段:

public void send(Response response) {
        String responseInString = JsonHandlingUtil.objectToJsonString(response);

        EventData eventData = new EventData(responseInString);
        // create a batch
        EventDataBatch eventDataBatch = producer.createBatch();

        // try to add the event from the array to the batch
        if (!eventDataBatch.tryAdd(eventData)) {
            // if the batch is full, send it and then create a new batch
            producer.send(eventDataBatch);
            eventDataBatch = producer.createBatch();

            // Try to add that event that couldn't fit before.
            if (!eventDataBatch.tryAdd(eventData)) {
                throw new IllegalArgumentException("Event is too large for an empty batch. Max size: "
                        + eventDataBatch.getMaxSizeInBytes());
            }
        }
        // send the last batch of remaining events
        if (eventDataBatch.getCount() > 0) {
            producer.send(eventDataBatch);
        }
        producer.close();
    }

我已经将eventhubproducerclient定义为一个bean。

@Bean
    public EventHubProducerClient eventHubProducerClient() {
        return new EventHubClientBuilder()
                .transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
                .connectionString(connectionString, eventHubName)
                .buildProducerClient();
    }

下面是我的gradle依赖项

>    //eventhub
>         implementation 'com.azure:azure-messaging-eventhubs:5.7.0'
>         implementation group: 'io.projectreactor', name: 'reactor-core', version: '3.4.6'

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题