This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMessagePublisher messagePublisher = MessagePublisherFactory.getPublisher(CacheType.CONNECTION_CACHE); | |
ExecutorService threadPool = Executors.newFixedThreadPool(5, factory); | |
for (int i = 1; i <= 1000000; i++) { | |
int finalI = i; | |
threadPool.submit(new Runnable() { | |
@Override | |
public void run() { | |
messagePublisher.publishMessage("testExchange", "testRoutingKey1", message + String.valueOf(finalI)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ChannelCachedMessagePublisher { | |
private static CachingConnectionFactory CACHING_CONNECTION_FACTORY = new CachingConnectionFactory("localhost"); | |
private static RabbitTemplate RABBIT_TEMPLATE; | |
private void init() { | |
if (!INITIALIZED) { | |
synchronized (ConnectionCachedMessagePublisher.class) { | |
CACHING_CONNECTION_FACTORY.setCacheMode(CachingConnectionFactory.CacheMode.CHANNEL); | |
CACHING_CONNECTION_FACTORY.setChannelCacheSize(100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.NullPointerException | |
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1198) | |
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1181) | |
at com.renderer.VelocityRenderer.merge(VelocityRenderer.java:84) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices(); | |
// renderKeyValueMap comprises of the java object(s) reference in | |
// velocity template as keys and java object(s) as values | |
VelocityContext velocityContext = new VelocityContext(renderKeyValueMap); | |
// Incorrect way of passing a custom template string for rendering | |
// Note that templateBody is pre-fetched from the database | |
StringReader reader = new StringReader(templateBody); | |
SimpleNode node = runtimeServices.parse(reader, templateBody); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:133) | |
at org.apache.velocity.runtime.log.Log4JLogChute.init(Log4JLogChute.java:85) | |
at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:157) | |
... 66 more | |
Caused by: java.io.FileNotFoundException: velocity.log (Permission denied) | |
at java.io.FileOutputStream.open0(Native Method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Indicate whether the Runtime is in the midst of initialization. | |
private boolean initializing = false; | |
//Indicate whether the Runtime has been fully initialized. | |
private volatile boolean initialized = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Configure Velocity Engine with NO LOG mode | |
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new NullLogChute()); | |
Velocity.init(); | |
VelocityContext velocityContext = new VelocityContext(renderKeyValueMap); | |
StringWriter populatedVelocityTemplate = new StringWriter(); | |
Velocity.evaluate(velocityContext, populatedVelocityTemplate, templateName, templateBody); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app; | |
@SpringBootApplication | |
// This annotation is a combination of @Configuration, @EnableAutoConfiguration and @ComponentScan | |
public class Application implements CommandLineRunner { | |
@Autowired | |
private StateMachine&lt;States, Events&gt; stateMachine; | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public StateMachineListener<States, Events> listener() { | |
return new StateMachineListenerAdapter<States, Events>() { | |
@Override | |
public void stateChanged(State<States, Events> from, State<States, Events> to) { | |
if (from == null) { | |
System.out.println("State machine initialised in state " + to.getId()); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="defaultPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> |
OlderNewer