Hi I am working on a JMS project where I need to take a message from a Message driven bean and print the contents to a network printer. Since we cannot use java.io in EJBs I am restricted to write the print file directly from MDB. Can anybody suggest what is the best way to print the message contents from an MDB. Also I am searching for a existing resource adapter to create a flat file from message contents and print to network printer. Any suggestions or ideas are appreciated. Pardha SCJP,SCWCD,SCBCD
A few warnings from experience: the javax.print stuff is not really designed for networked apps. We had problems with locating printers - you can't (for example) just give the PrintService an IP address or UNC path. Also the print service build its Printable objects up as Graphics - and so these can get unexpectedly big quite quickly, slowing down your app server. Formatting text can be tedious too. In the end we dropped the stuff to be printed onto the file system, and had a daemon process listening for new docs handle the printing (we have an MS environment, so this was just a quick WSF). This quite a bit easier, as well as more performant.
You could always create a JMS client that is deployed as an application-client to your EJB jar and run wherever your printer is. That way it can receive message from the same topic/queue, but won't slow down your application server. Oh, and you won't have any "warning" issues as far as using IO in your EJBs.