Skip to content

Instantly share code, notes, and snippets.

View calvincodes's full-sized avatar
😬
Breaking Things

Arpit Jain calvincodes

😬
Breaking Things
View GitHub Profile
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));
}
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);
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)
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);
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)
//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;
// 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);
package app;
@SpringBootApplication
// This annotation is a combination of @Configuration, @EnableAutoConfiguration and @ComponentScan
public class Application implements CommandLineRunner {
@Autowired
private StateMachine&amp;lt;States, Events&amp;gt; stateMachine;
public static void main(String[] args) {
@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 {
<bean id="defaultPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>