No… [root@cmhlcarchapp01 ~]# cat t.java import java.util.concurrent.*; public class t implements Runnable { static ArrayBlockingQueue Q = new ArrayBlockingQueue(5); String type; public static void main (String args[]) { t n = new t(“producer”); t n2 = new t(“consumer”); } public…
Category: Java
Listing all queues in ActiveMQ
This still has an issue with getting a consistent read. I will update this once I figure that piece out… import org.apache.activemq.*; import java.util.*; import org.apache.activemq.advisory.DestinationSource; import javax.jms.*; import javax.naming.*; import org.apache.activemq.*; import org.apache.activemq.command.ActiveMQQueue; public class ListQueues { public static…
Improving batch inserts into MySQL
We had a custom class to copy data from Oracle to MySQL at AWS. It was sending each statement individually, even though we batched them. import java.sql.*; public class test { public static void main(String args[]) throws Exception { Class.forName(“com.mysql.jdbc.Driver”);…
Good java decompiler
I had a need to find all classes that exposed a REST based interface. I couldn’t figure out how to do this with jd-gui, so this will be my new go-to for decompiling… https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler $ for f in $(find .…
Flexibly instrumenting java with CPU utilization recordings
Each of these has their own set of strengths, and is appropriate for differing and sometimes similar requirements. What each of them lack is the ability to flexibly, easily, and succinctly report on CPU utilization at not only an individual…
Simple JBOSS Fuse/Karaf Camel route deployment, part 2
A previous post provided a simple example of a karaf deployment with a Camel route. This one takes it a step further and provides a Camel processor that connects to another application, fetches content, and enhances it. The application properties…
Programatically gathering a thread dump
This is just a method you could add to your software if you wish to trigger a thread dump in a controlled fashion. import java.sql.*; import java.lang.management.*; public class DebugLocks { public static String dumpThreads() { final StringBuilder dump =…
What does web service do when client has socket timeout exceeded?
It should throw a broken pipe exception. Below shows an strace of a server socket when the client has timed out after not receiving a response in the time period it specified (setTimeout() method)… 13125 12:19:13.666786 ) = 1 ([{fd=7,…
Java garbage collection stats
jstat -gcutil -t 18987 1000 where 18987 is the java PID, and 1000 is the number of milliseconds (1 second) between samples 896794.7 0.00 0.00 4.01 5.63 98.94 9259 282.051 250 336.211 618.262 896795.7 0.00 0.00 5.31 5.63 98.94 9259…
Unexpected end of file from server
The “java.net.SocketException: Unexpected end of file from server” exception is thrown in the HTTPClient class, as well as others. This article simply provides an example of how to generate it for testing purposes. We start with a client class that…