I am working on a program that will listen to a queue of incoming message and will process each message differently depending on the metadata of that message. The messages must be processed in order and if a message fails to be processed, it will block the queue until that individual message is processed. The specific technology I am working with is Azure Service Bus, but it could be any queue implementation. The programs that consume the messages will be written in Java.
Is there a recommended approach or best practice for designing a program for consuming these messages?
My first thought was to create a single monolithic program that listens to the queue and processes each message itself. The reason I don't like this approach is that to change the processing of a single message type would require recompiling the entire project.
The other thought I had was to create an individual program for each message type that listens for its corresponding message type and processes it. The downside to this approach seems to be a lot of duplicated code (each program needs to be configured to read the queue). Plus, given the nature of Java, this would likely consume excessive resources.