GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes printing from MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "printing from MDB" Watch "printing from MDB" New topic
Author

printing from MDB

Pardha Akalamkam
Greenhorn

Joined: Mar 17, 2003
Posts: 10
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
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
You can still use java.io -- it's just your MDB "may not be portable". The line in the spec is a warning, not a full restriction. I'd go ahead and write it the way you want to with java.io.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
 
Consider Paul's rocket mass heater.
 
subject: printing from MDB