ioexception


How to cancel request using merge


Actually I am using RxAndroid, Retrofit2.0 and Okhttp 3.2.0 in my project.
I am using Observable.merge to call multiple request in order to upload files.
Is there any solution to cancel a unique request ? I know I could use subscription.unsubscribe() but it will cancel all tasks.
I Used okhttp method like client.dispatcher.get(0).cancel() but it throw me an Io Exception like Canceled and it will cancel all tasks.
Do you have a proper way to cancel only a selected request ? Thank you
You could attach use a takeUntil(Observable a) to each of your constituent Observables and use the "control" observable to selective cancel them. For example
PublishSubject<Object> control1 = PublishSubject.create();
PublishSubject<Object> control2 = PublishSubject.create();
Observable<T> cancellableRestrofitObservable1 = retrofitObservable1.takeUntil(control1.asObservable());
Observable<T> cancellableRestrofitObservable2 = retrofitObservable2.takeUntil(control2.asObservable());
Observable<T> mergedObservable = Observable.merge(cancellableRestrofitObservable1,cancellableRestrofitObservable2);
// To cancel retrofitObservable1
control1.onNext("cancel");
It's working well. This is the code:
PublishSubject control = PublishSubject.create();
publishSubjectMap.put(position, control);
Observable<Response<Upload>> cancellableRestrofitObservable = dropboxapi.uploadImage(requestBody, params, position)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.takeUntil(control.asObservable());
observables.add(cancellableRestrofitObservable);
Observable<Response<Upload>> mergedObservable = Observable.merge(observables);
//To cancel
publishSubjectMap.get(event.getPosition()).onNext("cancel");

Related Links

java.io.IOException: Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured
How to cancel request using merge
PrintWriter doesn't seem to be writing to file even though I'm closing it
StreamWriter.Writeline throws “Not enough storage is available to process this command.” IO exception
IO Exception in OSMembrane while executing pipeline
Exception in thread Main Error java.lang.numberformat.exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory

Categories

HOME
nam
automapper
adfs3.0
key
swi-prolog
subdomain
typeerror
bing-search
scheduler
fasm
match
slide
documentum
multi-step
django-rq
robolectric
nose
pe
azure-machine-learning
hdl
morris.js
window-managers
multi-dimensional-scaling
clipboard
math.js
miniprofiler
javax.persistence
unmarshalling
credit-card
es6-modules
john-the-ripper
universal
adminer
android-canvas
db2-luw
assertions
android-alarms
word-cloud
destroy
webalizer
sony-future-lab-n
ol3-google-maps
brightscript
nivo-slider
lvalue
apache-modules
emf-compare
rustdoc
bpms
ogg
mathjs
wininet
traversable
gnucash
odp.net-managed
adjacency-list
m4
textpattern
featuretoggle
compositetype
domino-designer-eclipse
ampersand
flow-js
dbmigrate
python-curses
android-audiomanager
fiware-bosun
nanomsg
configurable-product
xml-signature
inputbox
aho-corasick
coding-efficiency
reference-counting
wso2bam
proxy-server
application-blocks
eclim
application-server
tnt4j
microformats
spiral
user-forums
idispatch
server-name
sql-parametrized-query
bll
ccl
ninject-interception
asdoc
oracle-pro-c
subtext
eai
icon-language
version-control-migration
chronic

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App