From the course: Java EE 7: Enterprise JavaBeans (EJB)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Finalize message-driven bean

Finalize message-driven bean

From the course: Java EE 7: Enterprise JavaBeans (EJB)

Start my 1-month free trial

Finalize message-driven bean

- [Instructor] Okay, so let's keeps working on our message bean here. So the first thing we're going to do is continue working on this public void onMessage, so basically we need to determine what happens when we have a message. So how do we handle the message that's been given in our queue? So the first thing we're going to do is create the ObjectMessage and put it at null. And we need to import this guy here. And then let's do a try. And basically we're going to try this. If the message instance of ObjectMessage then do whatever's in here. So create a variable called message with the ObjectMessage. Then look into the RecordsEntity and create a new variable called e with the RecordsEntity, and then assign a message to it. And then save it. So we're handling messages as they come in. Now we need to insert a catch, so if we have an exception in our JMS system, e then print the stack trace, so basically print whatever is the error so we can see what's happening. Now what we'll do we'll…

Contents