小编Gar*_*ell的帖子

在Spring4.2.0中不支持iBatis

在Spring4.2.0中不支持ibatis.我的项目是从Spring 3.2.4升级到Spring 4.2.当我用Google搜索时,我发现了与mybatis的spring4.2集成示例,但没有使用ibatis.有人可以帮助我如何添加ibatis支持吗?

ibatis spring-orm

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

Spring mappingjackson2messageconverter给出空指针异常

我正在尝试将java对象转换为json格式,mappingjackson2messageconvertor但看起来它没有转换为json对象而是抛出nullpoint异常错误.想知道我做错了什么.

我在这里检查了一个例子.但我没有使用rabbitmq而不是我正在使用activemq.

资源

@SpringBootApplication
@EnableJms
public class Application {
    @Bean
    JmsListenerContainerFactory<?> myJmsContainerFactory(ConnectionFactory connectionFactory) {
        SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory);
        factory.setMessageConverter(new MappingJackson2MessageConverter());
        return factory;
    }


    public static void main(String[] args) {
        // Clean out any ActiveMQ data from a previous run
        FileSystemUtils.deleteRecursively(new File("activemq-data"));

        // Launch the application
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        AssetApi asset = new AssetApi();
        asset.setBroadcasterId("test");
        asset.setNotes("test");

        // Send a message
        MessageCreator messageCreator = new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException …
Run Code Online (Sandbox Code Playgroud)

spring-json spring-jms

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

Spring amqp批量接收消息

我们使用 Spring AMQP 从 RabbitMQ 读取消息,现在我们一次只能从队列中读取一条消息,我是否可以从队列中读取多条消息然后处理批处理?

我看到 Spring 中有一个 BatchingStrategy 可用,我如何将其插入到 connectionFactory 中?

这是我的代码:

CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
        connectionFactory.setUsername(username);
        connectionFactory.setPassword(password);

SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory);
        JsonMessageConverter converter = new JsonMessageConverter();
        DefaultClassMapper defaultClassMapper = new DefaultClassMapper();
        defaultClassMapper.setDefaultType(Message.class);
        converter.setClassMapper(defaultClassMapper);
        factory.setMessageConverter(converter);
        factory.setConcurrentConsumers(3);
Run Code Online (Sandbox Code Playgroud)

...

public class Processor implements IChannelProcessor {
@Override
    public void process(Message message) {
        validateMessageEvent(message);
        // process the message
Run Code Online (Sandbox Code Playgroud)

rabbitmq spring-amqp

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

禁用Apache tiles 3中的多语言选项

我正在接受Apche tiles 3和Spring MVC 4的警告我没有为多语言支持添加任何额外的配置,但它默认支持.任何人都可以帮我禁用此选项以在我的网站中删除此警告.

    org.apache.tiles.request.locale.PostfixedApplicationResource.
<init> No supported matching language for locale "sw". 
Using file:/opt/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/tiles/app-core_sw.xml as a non-localized resource path. see TILES-571
Run Code Online (Sandbox Code Playgroud)

tomcat spring-mvc apache-tiles tiles-3

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

如何在 Spring AMQP 中使用拦截器

在将消息传递到 RabbitMQ 之前,有没有办法在调用 template.convertAndSend 后拦截消息。

还有什么方法可以在到达处理程序之前拦截消息?

我可以使用 PostProcessor 处理发布者的消息,但更喜欢使用拦截器。

public class TestPostProcessor implements MessagePostProcessor {

    @Autowired
    Tracer defaultTracer;

    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        //.....
        //.... 
        return message;
    }
}
Run Code Online (Sandbox Code Playgroud)

有什么建议?

spring rabbitmq spring-amqp spring-boot

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

如何使用@RabbitListener停止使用消息

当我使用MessageListenerAdapter处理消息时,我可以调用SimpleMessageListenerContainer.stop()来停止从队列中消耗.但是在我改为使用@RabbitListener来监听之后,我找不到像这样的方法.我尝试过CachingConnectionFactory.stop()但不起作用.有人可以帮忙吗?非常感谢你.

spring rabbitmq spring-amqp spring-boot

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

SQSlistener 未接收消息

我能够从 springboot 向 SQS 队列发送消息,但无法使用 sqslistener 注释接收消息,有人可以帮忙吗?

public void send(String message) {


    queueMessagingTemplate.convertAndSend("test-queue", MessageBuilder.withPayload(message).build());
}

@SqsListener(value = "test-queue", deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void receive(String message)
{
    System.out.println("message: " + message);
}
Run Code Online (Sandbox Code Playgroud)

我已经验证通过 goign 发送到 AWS 控制台,我可以在队列中看到我的消息,但它们不会接收方法。配置:

@Bean
public AmazonSQSAsyncClient amazonSQSAsyncClient()
{

    AmazonSQSAsyncClient amazonSQSAsyncClient= new AmazonSQSAsyncClient(amazonAWSCredentials());

    if (!StringUtils.isEmpty(amazonSqsEndpoint)) {
        amazonSQSAsyncClient.setEndpoint(amazonSqsEndpoint);

    }

}

@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
    SimpleMessageListenerContainerFactory msgListenerContainerFactory = new SimpleMessageListenerContainerFactory();
    msgListenerContainerFactory.setAmazonSqs(amazonSQSAsyncClient());
    return msgListenerContainerFactory;
}

@Bean
public QueueMessagingTemplate queueMessagingTemplate(AmazonSQSAsync amazonSqs) {
    return new QueueMessagingTemplate(amazonSQSAsyncClient());
}

@Bean
public BasicAWSCredentials amazonAWSCredentials() { …
Run Code Online (Sandbox Code Playgroud)

amazon-sqs amazon-web-services spring-boot spring-cloud-aws

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

每次tomcat创建新Thread时如何运行DelegatingSecurityContextRunnable

我有一个使用带有websockets的tomcat的spring应用程序.每当tomcat创建一个新线程时,我想使用DelegatingSecurityContextRunnable,即warp tomcat线程.有谁知道这是怎么做的.可以找到问题的原因.这里

也许这可以通过使用AOP和一些建议来完成?

spring spring-security spring-boot

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

Spring Retry @Recover传递参数

我找不到任何有关需要采取行动的信息。我正在使用@Retryable注释和@Recover处理程序方法。像这样:

    @Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(delay = 10000))
    public void update(Integer id)
    {
        execute(id);
    }

    @Recover
    public void recover(Exception ex)
    {
        logger.error("Error when updating object with id {}", id);
    }
Run Code Online (Sandbox Code Playgroud)

问题是我不知道如何将我的参数“ id”传递给recovery()方法。有任何想法吗?提前致谢。

java spring recover spring-retry

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

springcloud-stream 和 springcloud-bus 有什么区别?

它们之间有什么区别?

springcloud-stream的实例之一springcloud-bus吗?
据我所知,他们都关心 MQ。

spring-boot spring-cloud-stream spring-cloud-bus

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