Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing from MDB

 
Pardha Akalamkam
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic