Skip to content

Instantly share code, notes, and snippets.

View adelinor's full-sized avatar
💭
Using the WebLogic app server and developing with Spring boot and camel

Adelino Rodrigues adelinor

💭
Using the WebLogic app server and developing with Spring boot and camel
View GitHub Profile
@adelinor
adelinor / ConsumerTest.java
Created January 31, 2019 22:22
Very simple consumption with MessageListenerContainer in a JUnit Test. This is inspired by https://www.logicbig.com/tutorials/spring-framework/spring-integration/jms-template-with-listener.html
package com.github.gist.adelinor.cameljmscalculator.messaging.config;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.jms.Message;
import org.junit.Ignore;
import org.junit.Test;
@adelinor
adelinor / JmsConfig.java
Last active June 17, 2019 21:25
This is an example of Spring Java Config class for a transactional Camel application which uses JMS. This config allows test running with @SpringBootTest to load the spring context without failure tanks to the exclusion of the PlatformTransactionManager bean.
@Configuration
@EnableJms
public class JmsTransactionConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(JmsTransactionConfig.class);
@Value("${app.jms.jndi-provider-url}")
private String jndiProviderUrl;
@Value("${app.jms.jndi-name}")
/**
* Implements a common retry policy for async operations
* @param fn Async method to retry if necessary
* @return Result of the function invoked
*/
private <T> ListenableFuture<T> invoke(Function<SharePointFacade, ListenableFuture<T>> fn) {
// Define an executor with Retry
RetryExecutor retryExecutor
= new AsyncRetryExecutor(this.scheduledExecutor)
.retryOn(AuthenticationExpiredException.class,
public ListenableFuture<FileSystemItem> createFile(String fileName, boolean overwrite, byte[] content) {
// ...
}
futureHandle = asyncMethod();
result = futureHandle.get();