Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

@Entity NNTPMessage

13 views
Skip to first unread message

Thufir

unread,
Apr 3, 2012, 4:00:01 AM4/3/12
to
I've got a poor-mans news reader, with three classes:

@Named bean: MessageBean
NNTP connection: SingletonNNTP
@Entity bean: MessageEntity

https://gist.github.com/2288307


It's apparently necessary to wrap gnu.mail.providers.nntp.NNTPMessage in
a container class, the @Entity class here. Is there a better way of
keeping NNTPMessage instances "alive" after the store and folder are
closed? It seems that closing the store and folder for the NNTPMessage
somehow invalidate the instance and cause socket errors when Facelets EL
tries to access the fields. Or, at least, using MessageEntity solves
socket problems.

Is there a better way to wrap NNTPMessage? I was thinking of extending
the class but inferred that would bring the connection woes along with
the benefits. It's a bit slow to load, but I don't think it's leafnode
per se. The leafnode response is quite quick and I'm not sure where the
bottleneck is, perhaps it's Glassfish itself.

Currently, SingletonNNTP grabs all messages for a specified newsgroup,
but it's quite laggy. How can I move that loading process to the
background? Currently, the backing bean MessageBean needs the entire
collection of MessageEntity instances for the DataModel. Maybe I could
just send a chunk of ten messages to the DataModel somehow?

How do I untangle these classes a bit? I was thinking of persisting all
the MessageEntity instances to a RDBMS, but would rather not, and don't
see how a connection to MySQL is inherently superior to Leafnode.


thanks,

Thufir

markspace

unread,
Apr 3, 2012, 10:36:27 AM4/3/12
to
On 4/3/2012 1:00 AM, Thufir wrote:

> It's apparently necessary to wrap gnu.mail.providers.nntp.NNTPMessage in

The "gnu" in that package name makes me nervous. The GNU Java
implementation is known to be broken. What is this class and where did
you get it?

> How do I untangle these classes a bit? I was thinking of persisting all
> the MessageEntity instances to a RDBMS, but would rather not, and don't
> see how a connection to MySQL is inherently superior to Leafnode.


That's basically what @Entity does. It persists your MessageEntity. If
you're just build in a NetBeans project, you'll be using JDB (Derby) as
your database by default.

In general, there are WAAAAAAAAAAYYYYYYYYY too many assumptions and
details left unspoken in your post. You've got three major frameworks
going, at least. (@Named: CDI/JSF, Leafnode: some open source,
compatibility with JEE unknown, @Entity: JPA). A lot is going to depend
simply on how well you read the documentation, and how you integrate the
three.

If you can create an SSCCE, I'll take a look at it, but I think creating
something that's actually short enough for others over the internet to
take their valuable time to sort out is going to be a tough sell.

<http://sscce.org/>

Thufir

unread,
Apr 3, 2012, 11:39:38 AM4/3/12
to
On Tue, 03 Apr 2012 07:36:27 -0700, markspace wrote:

> On 4/3/2012 1:00 AM, Thufir wrote:
>
>> It's apparently necessary to wrap gnu.mail.providers.nntp.NNTPMessage
>> in
>
> The "gnu" in that package name makes me nervous. The GNU Java
> implementation is known to be broken. What is this class and where did
> you get it?

http://www.gnu.org/software/classpathx/javamail/

Ah, well, it's much cleaner than Apache Commons. For whatever reason, an
Apache Commons NNTP Article has no body. Hmmm, a quick google doesn't
turn up anything. In what way is it broken?


-Thufir

markspace

unread,
Apr 3, 2012, 12:55:20 PM4/3/12
to
On 4/3/2012 8:39 AM, Thufir wrote:
> Ah, well, it's much cleaner than Apache Commons. For whatever reason, an
> Apache Commons NNTP Article has no body. Hmmm, a quick google doesn't
> turn up anything. In what way is it broken?


I'm talking about this:

http://gcc.gnu.org/java/

No worky. I don't use it, so I can't give you a list of bugs, but
they're known to be fairly major.

As for your NNTP client, I don't use GNU Javamail, so there's not a lot
I could help you with.

hawat....@gmail.com

unread,
Apr 3, 2012, 8:27:55 PM4/3/12
to
Oh, yeah, I use the Oracle JDK, although I'd prefer Open JDK. Yeah, I admire GNU, but they seem to bite off more than they can chew. Their Message class is light years ahead of the Apache Article, at least in terms of API.

However, let me run this by you, please. The connection to leafnode on localhost can just be left open, then I can omit the @Entity class and just go from the gnu Message to MessageBean (and a facelet) directly.

Because of some latency/lag/something, maybe just fetch headers, something like that, then full content per click message?

I'll have to read the API more closely, but does that make sense, to just send some articles? I'm not sure how Pan, for instance, does it, but it's quite rapid. Pan, I think, caches each article, however.

So, either getting just one header at a time, or, perhaps, caching articles? Does either approach seem superior?

Roedy Green

unread,
Apr 4, 2012, 9:57:00 AM4/4/12
to
On Tue, 3 Apr 2012 01:00:01 -0700, Thufir <hawat....@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>I've got a poor-mans news reader, with three classes:

I wrote a NNTP app that worked at the socket level. The idea was to
monitor newsgroups for new players then send them a welcoming email,
telling them where the FAQs were, and the newsgroup conventions.

Some complained of the "spam" and I had to stop using it.

You are welcome to the source. It is posted at
https://wush.net/websvn/mindprod/listing.php?repname=mindprod&path=%2Fcom%2Fmindprod%2Fwelcome%2F
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..

markspace

unread,
Apr 4, 2012, 6:25:37 PM4/4/12
to
On 4/3/2012 5:27 PM, hawat....@gmail.com wrote:

> However, let me run this by you, please. The connection to leafnode
> on localhost can just be left open, then I can omit the @Entity class
> and just go from the gnu Message to MessageBean (and a facelet)
> directly.

This I can't even parse. What kind of connection? What is leafnode?
Is it a server? Something else?

> So, either getting just one header at a time, or, perhaps, caching
> articles? Does either approach seem superior?


I use news.eternal-september.org as a news host, and they don't seem to
like the idea of caching the headers and then retrieving the article
body later, as two steps (which is what Mozilla Thunderbird does). I
guess it causes extra stress on their server.

As far as Pan and it being quick, it's just a TCP/IP connection. It
should run as fast as your internet can go. If not, there's either a
problem on their end or yours.


Thufir

unread,
Apr 5, 2012, 10:28:54 AM4/5/12
to
On Wed, 04 Apr 2012 15:25:37 -0700, markspace wrote:

> On 4/3/2012 5:27 PM, hawat....@gmail.com wrote:
>
>> However, let me run this by you, please. The connection to leafnode on
>> localhost can just be left open, then I can omit the @Entity class and
>> just go from the gnu Message to MessageBean (and a facelet) directly.
>
> This I can't even parse. What kind of connection? What is leafnode? Is
> it a server? Something else?

eternal-september.org is interesting, never knew about them. Leafnode is
a lightweight NNTP server which you can point at, for example, eternal-
september, or multiple other servers of course. I only use two, my ISP
and gmane. However, I think I'll add eternal september. They have a
nice FQDN registration! Anyhow, back to Java...

Part of the rationale for using Leafnode was to make things speedier by
having all the pieces on localhost.

I'm not sure on the internal workings of Leafnode, I'll have to look into
it. However, it presumably only allows a small number of connections.
Apparently one option is to just leave the socket open. If the socket is
open, then the need for an @Entity wrapper/container for NNTP messages is
obviated. It's then possible to go straight from gnu NNTPMessage to a
@Named backing bean.

However, it's not totally reliable, because maybe leafnode will drop
connections unexpectedly, or something else might happen, and the
connection will be dropped. Maybe timeout, etc.

So, I will have to read the GNU API, but I was thinking of just sending,
say twenty messages at a time instead of the entire group. Just not
quite sure how get the facelet to then say "ok, get next message" and
handle the error messaging.

It's more complex in some ways then using an @Entity, but somewhat
preferable because it leaves all the messages on leafnode without
duplicating them. Although I suppose I'll want to add some flags like
"message read" or things along those lines, and will have to put those in
a RDBMS.

Hopefully that's clearer! It's not clear to me, just thinking out loud.




thanks,

Thufir

Thufir

unread,
Apr 5, 2012, 10:31:20 AM4/5/12
to
On Wed, 04 Apr 2012 06:57:00 -0700, Roedy Green wrote:


> Some complained of the "spam" and I had to stop using it.
>
> You are welcome to the source. It is posted at
> https://wush.net/websvn/mindprod/listing.php?repname=mindprod&path=%
2Fcom%2Fmindprod%2Fwelcome%2F

Well, yeah, ISP's have rules against automated NNTP. Even using leafnode
violates their TOS, never mind automated messages!

I'll take a look at that, thank you for the link. Is there a reason you
didn't use either GNU or Apache lib's?


-Thufir
0 new messages