Skip to content

Commit 3d188ce

Browse files
authored
Merge pull request #38 from jui8wang/readme
Readme
2 parents da87682 + 8c3231e commit 3d188ce

File tree

2 files changed

+76
-60
lines changed

2 files changed

+76
-60
lines changed

README.md

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,107 @@
11

22

3-
# IMAP NIO client in Java
4-
Java IMAP nio client that is designed to scale well for thousands of connections per machine and reduce contention when using large number of threads and cpus.
3+
# imapnio
4+
A Java library that supports NIO (Non-blocking I/O) based IMAP clients.
5+
6+
The IMAP NIO client provides a framework to access an IMAP message store using None-blocking I/O mechanism. This design scales well for thousands of connections per machine and reduces contention when using a large number of threads and CPUs.
57

68

79
## Table of Contents
810

11+
- [Background](#background)
912
- [Install](#install)
1013
- [Usage](#usage)
1114
- [Contribute](#contribute)
1215
- [License](#license)
1316

17+
18+
## Background
19+
20+
The traditional accessing IMAP message store uses [JavaMail API](https://www.oracle.com/technetwork/java/javamail/index.html), which requires a blocking I/O. In this case, threads are blocked when performing I/O with the other end. This project was developed to relieve the waiting thread to perform other tasks, and it's design efficiently improves thread utilization to maximize hardware throughput and capacity.
21+
22+
Some of the more distinguishing features of this library are:
23+
- Highly customizable thread model and server/client idle max limit.
24+
- Leverages the well-established framework [Netty](https://netty.io/)
25+
- Future-based design enables a clean separation of IMAP client threads pool versus consumers threads pool.
26+
- IMAPv4, [RFC3501](https://tools.ietf.org/html/rfc3501) support.
27+
- ID command, [RFC2971](https://tools.ietf.org/html/rfc2971) support.
28+
- IDLE command, [RFC2177](https://tools.ietf.org/html/rfc2177) support
29+
- MOVE command, [RFC6851](https://tools.ietf.org/html/rfc6851) support
30+
- UNSELECT command, [RFC3691](https://tools.ietf.org/html/rfc3691) support
31+
32+
This project is ideal for applications that have a high requirement to optimize thread utilization and improve overall resource capacity. Specifically, this is best for situations where users perform a very high level of sessions and communication with the IMAP server.
33+
1434
## Install
1535

16-
This is packaged as a java library and can be imported as maven or gradle dependency in your project. There are no special installation instructions.
17-
$ mvn clean install
36+
This is a Java library. After downloading it, compile it using `mvn clean install`
1837

19-
- For contibutors run deploy to do a push to nexus servers
20-
$ mvn clean deploy -Dgpg.passphrase=[pathPhrase]
38+
Then, update your project's pom.xml file dependencies, as follows:
39+
```
40+
<dependency>
41+
<groupId>com.github.krdev.imapnio</groupId>
42+
<artifactId>imapnio.core</artifactId>
43+
<version>1.0.23</version>
44+
</dependency>
45+
```
46+
Finally, import the relevant classes and use this library according to the usage section below.
2147

48+
- For contributors run deploy to do a push to nexus servers
49+
```
50+
$ mvn clean deploy -Dgpg.passphrase=[pathPhrase]
51+
```
2252

2353
## Usage
2454

25-
Compile and use it as a regular IMAP client.
55+
The following code examples demonstrate basic functionality relate to connecting to and communicating with IMAP servers.
56+
57+
### Create a client
58+
```java
59+
// Create a IMAPClient instance with number of threads to handle the server requests
60+
final int numOfThreadsServed = 5;
61+
final IMAPClient imapClient = new IMAPClient(numOfThreadsServed);
62+
```
63+
### Establish a session with an IMAP server
64+
```java
65+
// Create a new session via the imap client created above and connect to that server. For the illustration purpose,
66+
// "imaps://imap.server.com:993" is used
67+
final IMAPSession session = imapClient.createSession(new URI("imaps://imap.server.com:993"), new GenericListener(), new LogManager());
68+
// connect to the remote server
69+
session.connect();
70+
```
71+
72+
### Execute the IMAP command to IMAP server
73+
Following codes uses a Capability command as an example.
74+
75+
```java
76+
// Instantiates your own IMAPCommandListener instance
77+
final IMAPCommandListener listener = new MyOwnIMAPCommandListener();
78+
// fire CAPABILITY command with the tag name you want to track
79+
final String tagName = "A0001";
80+
session.executeCapabilityCommand(tagName, listener);
81+
```
82+
83+
### Handle the response from IMAP server
84+
onMessage() method will be called on the registered IMAPCommandListener.
85+
Following example shows how to read IMAPResponse sent from the server.
2686

2787
```java
28-
// Create a new session
29-
final IMAPSession session = theClient.createSession(new URI("imaps://imap.server.com:993"), new GenericListener(), logManager);
30-
// connect to the remote server
31-
session.connect();
32-
// fire OAUTH2 command
33-
session.executeOAuth2Command(...);
88+
@Override
89+
public void onMessage(final IMAPSession session, final IMAPResponse response) {
90+
System.out.println("Response from IMAPServer is==>tag:" + response.getTag() + ",getRest():"
91+
+ response.getRest() + ",toString():" + response.toString());
92+
}
3493
```
3594

95+
3696
## Contribute
3797

3898
Please refer to the [contributing.md](Contributing.md) for information about how to get involved. We welcome issues, questions, and pull requests. Pull Requests are welcome.
3999

100+
40101
## Maintainers
41102

42-
Luis Alves: (lafa at verizonmedia.com)
103+
Luis Alves: lafa@verizonmedia.com
104+
43105

44106
## License
45107

README.txt

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)