小编Jer*_*och的帖子

Apache Camel Endpoint注入直接路由"端点上没有可用的消费者"

我想使用Camel从ActiveMQ接收消息,然后根据消息内容(protobuf)向Twitter发送一条或多条消息.我编写了一个从路由中调用的bean,它使用注入将多个消息发送到"direct:xyz"端点.

但是,Camel在运行时抱怨:

2012-11-16 09:56:33,376 | WARN  | ication.twitter] | DirectProducer                   | 160 - org.apache.camel.camel-core - 2.10.2 | No consumers available on endpoint: Endpoint[direct://twitter] to process: Exchange[Message: hello world]
Run Code Online (Sandbox Code Playgroud)

如果我从bean内直接注入Twitter端点,它可以正常工作.但是,为了便于测试,简化配置等,我想将实际的Twitter配置分开,因此希望发送到单独的路由.

驼峰上下文配置如下: -

<camelContext id="NotificationTwitter"
    trace="false" xmlns="http://camel.apache.org/schema/blueprint">
    <dataFormats>
        <protobuf id="notificationProto" instanceClass="org.abc.schemas.protobuf.NotificationDef$NotificationMsg" />
    </dataFormats>

    <route id="TwitterPreparation">
        <from uri="activemq:notification.twitter" />
        <unmarshal ref="notificationProto" />
        <log logName="abc" loggingLevel="INFO"
            message="Twitter request received: ${body}" />
        <bean ref="NotificationTweeter" method="createTweets" />
    </route>

    <route id="Twitter">
        <from uri="direct:twitter" />
        <log logName="abc" loggingLevel="INFO"
            message="Tweeting: ${body}" />
        <to uri="twitter://timeline/user?consumerKey=itsasecret&amp;consumerSecret=itsasecret&amp;accessToken=itsasecret&amp;accessTokenSecret=itsasecret" />
    </route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)

豆看起来像: - …

apache-camel endpoint blueprint

14
推荐指数
2
解决办法
3万
查看次数

Azure KeyVaultAccessForbidden-“未启用部署”

我正在构建一组脚本和模板以在Azure中创建Service Fabric群集。我有一个脚本,该脚本创建密钥库和自签名证书,并将其成功上传到库中。另一个脚本创建了群集,但是在证书链接到虚拟机时出现了错误。该New-AzureRmResourceGroupDeployment命令的错误是:-

{
  "status": "Failed",
  "error": {
  "code": "ResourceDeploymentFailure",
  "message": "The resource operation completed with terminal provisioning state 'Failed'.",
  "details": [
    {
      "code": "KeyVaultAccessForbidden",
      "message": "Key Vault https://VAULT-NAME.vault.azure.net/secrets/clusterCert/SECRET-ID either has not been enabled for deployment or the vault id provided, /subscriptions/SUBSCRIPTION-ID/resourceGroups/jg-sf/providers/Microsoft.KeyVault/vaults/VAULTNAME, does not match the Key Vault's true resource id."
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

}

VAULT-NAME,SUBSCRIPTION-ID和SECRET-ID均正确。密钥库已使用参数创建"enabledForTemplateDeployment": true,如以下屏幕截图所示。

密钥库配置屏幕截图

我的脚本和模板可以在GitHub- https://github.com/goochjs/azure-testbed中看到。

我如何诊断问题?

谢谢,

杰里米

azure azure-resource-manager azure-service-fabric azure-keyvault azure-template

7
推荐指数
1
解决办法
2887
查看次数

JMSExpiration与TimeToLive

我正在尝试在Blueprint XML Camel路由中设置消息过期.我想要设置为到期的值保存在消息体(protobuf)中.

这是我的代码: -

<setHeader headerName="AMQ_SCHEDULED_DELAY">
    <method bean="NotificationScheduler" method="postponeSending" />
</setHeader>
<setHeader headerName="JMSExpiration">
    <method bean="NotificationScheduler" method="getExpiry" />
</setHeader>
<setHeader headerName="ExpirationTest">
    <method bean="NotificationScheduler" method="getExpiry" />
</setHeader>
<to uri="activemq:notifications.splitter" />
Run Code Online (Sandbox Code Playgroud)

正如您在下面的屏幕截图中看到的,我成功设置了三个标题中的两个,但"JMSExpiration"的设置(根据此主题)没有任何效果.

ActiveMQWeb片段

我知道我也可以使用收件人列表模式动态设置uri - 即从消息数据中提取到期日并附加?timeToLive=...选项.然而,这对我来说似乎有点笨拙.

有没有办法通过XML中的setHeader设置过期?

谢谢,

J.

activemq-classic jms apache-camel

6
推荐指数
1
解决办法
4943
查看次数

由于对象的当前状态(System.Text.Json),操作无效

我们有一个 API,它只是将传入的 JSON 文档发布到消息总线,并为每个文档分配了一个 GUID。我们正在从 .Net Core 2.2 升级到 3.1,并打算用新System.Text.Json库替换 NewtonSoft 。

我们反序列化传入的文档,将 GUID 分配给字段之一,然后在发送到消息总线之前重新序列化。不幸的是,重新序列化失败了,例外Operation is not valid due to the current state of the object

这是一个显示问题的控制器:-

using System;
using System.Net;
using Project.Models;
using Microsoft.AspNetCore.Mvc;
using System.IO;
using System.Text;
using System.Text.Json;

namespace Project.Controllers
{
    [Route("api/test")]
    public class TestController : Controller
    {
        private const string JSONAPIMIMETYPE = "application/vnd.api+json";

        public TestController()
        {
        }

        [HttpPost("{eventType}")]
        public async System.Threading.Tasks.Task<IActionResult> ProcessEventAsync([FromRoute] string eventType)
        {
            try
            {
                JsonApiMessage payload;

                using (StreamReader reader …
Run Code Online (Sandbox Code Playgroud)

c# json .net-core-3.1 system.text.json

6
推荐指数
1
解决办法
3531
查看次数

Azure Devops 中针对不同环境的 app.config 转换

我有一个 .Net Framework 4.6.1 项目,它创建了一个 Windows 服务。我们希望通过 Azure Devops 管道构建和部署它。我们已经成功地为我们所有的 .Net Core web 服务创建了管道(使用 ASPNETCORE_ENVIRONMENT 变量和一组 appsettings.{ENV}.json 文件)但是 Windows 服务在提供不同的不同环境的配置。

我有适用于 App.config XML 文件的 XDT 转换。我可以右键单击 Visual Studio 中的文件和“预览转换”,它工作正常。

不清楚的是我如何将其转换为管道配置。Build 任务似乎能够运行转换,但我不确定我们如何为不同的 Deploy 阶段进行不同的转换。相反,所有环境最终都会将任何转换应用于作为构建步骤的一部分选择的构建配置。

我已经关注了许多博客文章 - 包括这篇文章,它声称您可以有多个构建配置,但我似乎没有设置。

我错过了什么?

c# azure-devops azure-pipelines-build-task azure-pipelines

5
推荐指数
1
解决办法
4413
查看次数

记录骆驼异常并发送到死信通道

我在卡拉夫内有一条骆驼路线,为此我添加了一个死信通道。这是为了处理路由失败并且我想保留问题消息并记录原因的情况。由于无法异步处理某些处理,因此无法将异常返回给调用应用程序。

通过阅读文档并尝试了多种情况,我不清楚如何将异常记录到Karaf的日志中以及将原始消息存储到死信队列中。

这是我所拥有的内容的摘录:

<bean id="deadLetterQueue" class="org.apache.camel.builder.DeadLetterChannelBuilder">
    <property name="deadLetterUri" value="activemq:dead.letter.queue"/>
    <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
</bean>

<bean id="redeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
    <property name="maximumRedeliveries" value="1"/>
    <property name="redeliveryDelay" value="1000"/>
</bean>

<camelContext id="notification" errorHandlerRef="deadLetterQueue"
    trace="false" xmlns="http://camel.apache.org/schema/blueprint">
    <onException>
        <exception>org.xyz.exceptions.unchecked.notificationException</exception>
        <log logName="notifications" loggingLevel="ERROR"
            message="Exception from notification Camel route" />
    </onException>

    <route id="DoSomething" errorHandlerRef="deadLetterQueue">
        <from uri="activemq:notification.in" />
        <log logName="notifications" loggingLevel="TRACE"
            message="Notification route initiated" />
        <bean ref="NotificationProcessor" method="doStuff" />
    </route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)

如果删除“ onException”结构,则在所有异常情况下,源消息都会出现在死信队列中,但不会记录。

如果我按上述方式运行,则异常跟踪将记录到Karaf的日志中(如果它是“ notificationException”),但是相关的源消息不会回滚到死信队列,而会消失在以太币中(大概是因为它认为我是ve在“ onException”结构中进行了处理)。

看了不同类型的错误处理程序后,我尝试改为向DeadLetterChannelBuilder添加内容,例如...

<property name="logName" value="notifications"/>
<property name="level" value="ERROR"/>
Run Code Online (Sandbox Code Playgroud)

...但是这些不是合法财产。

这也让我感到震惊,不得不在onException子句中明确列出不同的异常是不正确的。

因此,如何获取死信通道以记录异常跟踪以及将消息放入队列?死信通道可能不是正确的处理程序-在这种情况下,我对自动重新交付并不真正感兴趣。

感谢您的指导,

J.

logging exception-handling apache-camel apache-karaf

4
推荐指数
2
解决办法
1万
查看次数

如何通过websockets保护MQTT

我想了解在通过websockets将MQTT代理映射到浏览器时保护Mosquitto的最佳方法.我正在使用Lighttpd作为websocket层,根据这篇博客文章.

我的用例是单向的.我只需要向浏览器发送消息.因此,我可以使用ACL来防止恶意分子发布消息.

但是,我怎样才能阻止歹徒订阅,或者更好的是,首先建立连接?

我知道我可以使用ID/pw进行MQTT连接.所以,我猜我的应用服务器可以在用户自己验证后将凭据发送到浏览器,然后Javascript客户端可以使用这些凭据来建立MQTT/WS连接.但是,如果我有数千个客户端,我该如何管理ID和密码?或者我应该只有一些ID并定期回收它们?我是否应该根据mosquitto-auth-plug将此位移至Redis或类似位置?

通过保护webserver层中的连接,我想知道是否有更好的方法.Lighttpd 的mod_secdownload插件似乎提供了一个模型,可以根据共享密钥(保留服务器端)和时间戳的哈希动态生成URL.用户通过身份验证后,应用服务器将向下传递此URL,然后客户端将使用它来建立到MQTT代理的连接.过了一会儿,URL将过期,Javascript客户端可以捕获此异常,如果用户仍然经过身份验证,则可以请求新的WS连接URL.这与许多API身份验证类似.它有价值吗?

有更好的方法吗?

谢谢,J.

security authentication lighttpd mqtt mosquitto

4
推荐指数
1
解决办法
6339
查看次数